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 checkout 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.
If you are certain this is the direction you want to take your history, you should start by checking out the master branch and interactively rebasing it ( git rebase -i ) onto the commit where feature was cut from (in your case, [M2] ).
Merging is a safe option that preserves the entire history of your repository, while rebasing creates a linear history by moving your feature branch onto the tip of main .
From a content perspective, rebasing is changing the base of your branch from one commit to another making it appear as if you'd created your branch from a different commit. Internally, Git accomplishes this by creating new commits and applying them to the specified base.
While merging is definitely the easiest and most common way to integrate changes, it's not the only one: "Rebase" is an alternative means of integration.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With