Migrating from SVN to Git?
首先我們需要在Stach或者GitHub上新建一個Repository, 拿到它的URL。 接下來參照如下步驟 :
At first we should create a new git repository at Stash and get the repository URL, and then follow below steps:
1. 切換到本地git工作目錄
? ? change to the git working directory :?
? ? $cd c:/git
?
2. 將svn目錄格式轉換為git形式, 可選為標準格式或Trunk格式
? ? --import the contents (svn repository) into the new Git repository:?
? ? this command transform the trunk, branches, and tags in SVN repostory into a new repository.
? ? Depending on different structure of SVN layout, we need different parameter for this command.
? ? [1] $git svn clone [svn repository url] -s
? ? ? ? ?-s : standard layout, there should be trunk,branches, and tags for SVN repository.?
? ? [2] $git svn clone [svn repository url] -t Trunk
? ? ? ? ?-t Trunk : ?only for trunk?
? ? ? ? ?
3. 連接同步本地庫和遠程庫
? ? $git remote add origin [git repository url]
? ? this command is used to add a remote which is just a shotcut for the git repository url.
? ? Now we use the command to add a remote "origin" for our new git repository
? ?
4. 推送本地代碼到遠程分支
? ? $git push origin --all
? ? this command push all the local repository to bitbucket repository.
?
? ? If you just need to push specific branch, such as "master" , use this command :
? ? $git push origin master
?
? ? After these , Bitbucket repository is now a clone of local repository, we can check the history at the Stash.