3

I'm using git-svn and have been working on a local topic branch for a series of commits and have run into some trouble merging my changes back into the master.

These are the steps that have gotten me to where I'm at:

git commit  (on topic branch)
git checkout master
git svn fetch (numerous files pulled down from origin)
git merge <topic branch>

At this point I had a merge conflict which I fixed and then did a git add <file> to add my fixed file.

Now my git status reports that all of the files (included all those fetched from the server) are changes to be committed. I forgot to do a git svn rebase which I'm thinking is my problem.

I'm fairly new git in general so I'm not even sure if what I'm seeing is expected behavior but it seems suspect. Did my forgotten git svn reabse get me into trouble? What do I do to get out of this potential mess?

4

1 回答 1

2

Assuming you were working with trunk, discard your merge commit

git reset --hard remotes/trunk

Catch up with any changes in Subversion

git svn fetch
git svn rebase

Now you have two options. You could rebase the work on your topic branch and merge it:

git checkout <topic branch>
git rebase remotes/trunk
git checkout master
git reset --hard remotes/trunk
git merge <topic branch>
git svn dcommit

You might prefer squash-merge instead, which means balling all changes on a branch into a single commit. Discard, fetch, and rebase as above and then

git merge --squash <topic branch>

Clean merges will go to the index which you can review with

git diff --cached

Any conflicts will be left in the work tree, and you can see them with

git diff

Resolve any conflicts, stage them with git add, and then git commit to wrap up your new commit.

于 2013-01-14T03:21:15.960 回答