I am using git as a version control system, and using git-flow as the branching model. I started a feature branch some weeks ago in order to maintain the system in a clean state while developping that feature. The main development continued on the develop
branch, and changes from develop were merged periodically into the feature, to keep it up to date as much as possible.
However came the time where the feature was finished, and I used git-flow's finish feature
to merge the feature back into develop. The merge was successfully done, but then I found out that some of the commits I made in develop were reverted by the merge commit!
Nowhere in develop
or in the feature branch were these changes reverted, I can't see any commit that overwrote them. I just can't find anything. The only theory I have for the moment is that git is failing on me, but that would be extremely unlikely. Maybe I did some kind of wrong manipulation that made this situation come true?
I can trace back in the history when the commit was made. I can see that the changes from that commit were reverted by the merge commit. Nowhere in the branch I see a commit that reverts those changes. Yet they were reverted.
How is this even possible?
2 Answers 2
Finally, it was an error on my part. I recently migrated the projet from SVN to Git, and I had then feature branch in SVN and it was not in sync with the trunk when I made the migration.
I created the first commit in the develop branch with the trunk, and then started a new feature-branch with git, and commited the files as they where in the SVN feature branch.
The commit being newer on the feature branch, and because it was not in sync with the latest trunk changes, Git thought, and for a reason, that the reverted changes were made after the initial commit, bringing these changes in when I merge the branch back into develop.
I resolved this in a separate branch, with a lot of manual work, but now I know that it was not git's fault.
I had also same problem, it is more safe to checkout a new temporary branch from your main branch, merge and test this temporary branch and merge, if you are sure you did not miss something, merge to your main branch.
If you have a working version of your code, convert it to a new release, or a branch with a descriptive tag and do not touch it, and go on with development branch.
And avoid direct merging as far as possible, instead use rebase
command, before merging. it is like stash
command.
-
A branch in another repository is always a different branch. So as long as you don't merge in the central repository (which you usually can't because it is bare), you always have a temporary branch.Jan Hudec– Jan Hudec11/13/2013 07:46:08Commented Nov 13, 2013 at 7:46
-
git log --left-right --boundary L...R
forL
andR
being the commits merged would be a start.