I\'m using git-svn
to work with an SVN repository. My working copies have been created using git svn clone -s http://foo.bar/myproject
so that my w
When there are no changes on trunk, git does a fast-forward merge and simply sets the local "master" branch to the commit on your branch. Git-svn doesn't know how to commit fast-forward merges back to trunk, in fact it thinks "master" now is pointing to the svn branch.
To work around this, use git merge --no-ff
when merging. This will force git to create a merge commit, which can then be dcommitted to svn.
I had the same problem, and I merged remotes/trunk back into master after which git svn info pointed back to trunk
I didn't have the time to actuall dcommit as I was leaving the project and my git-svn repo died with my worstation. I did trythe dcommit --dry-run and it said it would commit back to trunk.
I'll reproduce the setup and test when I get the time
cheers
In general, you should not use git merge
with git svn
, because svn, even with branches, doesn't support the kind of merge tracking that git does. When you need to merge a branch, I've had the most success (at least with recent svn) doing a plain svn checkout/merge process and then using git svn rebase
to update my git-svn repositories. This preserves svn's native merge tracking metadata, which (AFAIK) git-svn
is completely ignorant of.
I'm not totally sure what state your svn repository is in -- I would check to make sure the merge dcommit did what you wanted it to on the trunk. Even if it did,
I bet if you look at the contents of the refs/heads/master
and refs/remotes/trunk
files in your repo, you'll see that they're different at the moment. If that's the case, I would (with no local changes present) do a git-svn fetch
followed by a git branch -f master remotes/trunk; git reset --hard master
to resync the git branch with the git-svn tracking branch. If you have local changes, you'll have to commit and do something like git rebase master^4 --onto remotes/trunk
, where 4 is the number of commits you need to preserve. Alternatively, if they're all uncommitted, stash them with git stash
first.
Failing that, you can always get everything into svn and just wipe the repo and get a fresh checkout.
If you git svn rebase
after switching back to master and use --squash you can avoid this.
# git checkout master
# git svn rebase //(<--the missing step)
# git merge --squash mybranch // (<-- doesn't commit, more like an svn merge would do)
... (successful)
# git add .
# git commit -m '...'
# git svn dcommit
Committing to http://foo.bar/myproject/trunk...
#
To solve the current state (i.e. your master is pointing to an SVN branch)
You can 'switch' to another branch, delete master, 'switch' back to it and then merge again:
# git checkout mybranch
# git branch -D master
# git checkout -b master trunk
... continue with merge...
# git merge --squash mybranch
... you now have mybranch merged into master and ready to commit
and then dcommit
to trunk
If you haven't made any commit on master, that means the git merge mybranch
was a fast-forward one: master HEAD
simply move to mybranch HEAD
.
That could explain why the git svn dcommit
pushed your changes to the SVN mybranch
.
It would:
mybranch
commits not yet dcommitted, I don't think master hasn't change its reference, but if you have a doubt (and your working directory is clean), you could (if master is currently checked out):
git reset --hard remotes/trunk
We have successfully used git merge --squash
in git-svn feature branch development. The problem with git-svn is that while your local git-svn clone can store the merge information, once you dcommit to the svn repository, it is lost.
So for other (git-)svn users the merge commits look just like plain commits. The squash is good for the same thing as git merge --no-ff
(eg. producing a merge commit on master), but it also includes a list of the actual commits made in the branch being merged, which would otherwise be lost when dcommitting.