开发者

git is stating a branch is not merged after rebasing - why?

开发者 https://www.devze.com 2023-02-19 03:22 出处:网络
I\'m using git-svn to manage my bugfix branches, but it tells me that I have unmerged changes, even though if I review the SVN repo directly, I can see they have been committed too. It\'s like the reb

I'm using git-svn to manage my bugfix branches, but it tells me that I have unmerged changes, even though if I review the SVN repo directly, I can see they have been committed too. It's like the rebase of the bug fix is not setting the branch as merged.

What am I doing wrong, here?

git checkout -b fix_bug_1234

git add .
git commit -m "first change"
git add .
git commit -m "second change"

git rebase -i HEAD~2 // squash the two changes together

git svn rebase // fetch any changes from svn

git che开发者_开发百科ckout master
git rebase fix_bug_1234
git svn dcommit

git branch -d fix_bug_1234
error: The branch 'fix_bug_1234' is not fully merged.


The reason for that is that git rebase changes the commit objects. So while the actual content (or diff) is the same with those rebased commits, they are referring to a different parent, and as such are different.

That way git branch -d cannot verify that the changes of those commits are included in some other commits. You need to use git branch -D (uppercase D) to force the deletion then.

On a side note: git svn dcommit has the same effect as rebasing. As dcommit pushes the commits to the SVN server, it afterwards gets the commits from the SVN server again. So you end up with different objects than the ones you pushed. Although they may be identical in content (unless you had conflicts), they still differ (main reason is that git svn adds a line to the commit message stating the SVN version the commit belongs to).


Here is how I do this sort of thing, and it works. The answer from user poke explains why the git rebase is not doing what you want it to.

git rebase -i HEAD~2 // squash the two changes together

git svn rebase // fetch any changes from svn
git svn dcommit  // you can commit to SVN from any branch

git checkout master
git svn rebase
git branch -d fix_bug_1234
0

精彩评论

暂无评论...
验证码 换一张
取 消