简体   繁体   中英

How Can I Do Git SVN Correctly?

In a work environment, our version control is Subversion, and that's unlikely to change. I want to use Git locally, mostly for the advantage of local repositories.

Context

Base URL: http://www.example.com/code (with ./trunk , ./branches , ./tags ).

Using TortoiseGit, I was able to specify which one to check out. I'd like to have all branches, tags, and trunk available locally. This means, I'd be able to merge from a local branch back into a master, based on one of the remote branches if required.

How do I do this correctly?

After this long process completed, I tried to rebase to remotes/branches/EXAMPLE-BRANCH1 using TortoiseGit's 'SVN Rebase', going from master to remotes/branch/test-branch . This failed, saying that master was way behind.

When I tried going from master to a local branch based on remotes/branch/test-branch , the merge didn't work.

To clone your repo including all trunk/branches/tags with the standard layout (as you mention you have):

git svn clone -s http://www.example.com/code new-repo-directory

NOTE: Using git is not a silver bullet. You will still have merge/rebase conflicts that you will need to resolve. You will probably have much less of them, but they will not go away entirely. The failure was probably accurate and indicates that you need to resolve the conflicts then finish your rebase with git rebase --continue .

I'm sure Tortoise is a great help for many things. But I've been told many times over that you will get much more out of git if you learn to use the command line (and I believe I agree) and only use GUI helpers as tools once you understand what it is they are doing behind the scenes.

PS -- git svn rebase is for applying changes made in SVN on top of your current SVN tracked branch. If you are trying to merge 2 different SVN tracked branches you will want to use git checkout branch-to-update then git rebase branch-with-updates (and resolve any conflicts, then git add the-conflicted-file and git rebase --continue until it is finished).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM