I have a branch which I've merged into master.
On the branch, git log file shows a commit on February 9
On master, git log file does not show the commit on February 9th
On master, git log does show the February 9th commit
The file does not reflect the changes made on February 9th, yet git log shows the commit. It appears git merged in the commit, but didn't actually apply it to the file. What could be causing this?
Edit: I think I figured out what happened and answered below. I cleaned up the original question for clarity. I had originally written I thought this to be a bug with git, but I don't think that's the case anymore. It would be nice, however, if git log file did show these commits to the file. Thanks to everyone who helped, especially Borealid.
Earlier Edit: I genuinely believe this is a bug with git. This file was never renamed, yet git believes that it was, and that is why the commit isn't being applied. I created another branch, performed the merge, and this problem didn't occur. I can reproduce the bug on the branches where this occurred. I would be happy to help any git developer debug the problem with me, but I can't send you my repository.
Quoted from Dave:
I've recreated a similar situation with the following steps:
- Create a new git repository
- Create a file with one line, add it to git and commit (commit #1)
- Create and switch to a branch
- Change the file in the branch, commit (commit #2)
- Switch to master, change the file so there will be a conflict and commit (commit #3)
- Merge branch into master, the file will be in conflict
- Resolve the conflict by taking all the changes in master, and rejecting all the changes in the branch. Basically, the file should look as it did in master.
- Add the file and commit the changes (commit #4)
Now git log will show all four commits, but git log file will only show commits #1 and #3
The reson that git log -- file only show commit #1 and #3 is because how git-log (default mode) walks the commit chain; when a merge commit is found and there exists a parent commit such that the selected file has the same content after the merge as in the parent commit, git-log will follow (one) such parent and reject all other parents.
In this case, since the merge conflict is resolved by only keeping changes made in master (the file will have the same content in commit #1 and commit #4) git-log will only walk the master branch.
In more details: http://schacon.github.com/git/git-log.html (section "History Simplification")
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