So I was working on a file and committed it to my tracking branch and pushed up to the remote branch. Someone else must have made a change to the same file and had a conflict with my change and they resolved the issue, but removed my edits as the resolve. There was an error when they went to the application the next time and realized it was with something I was working on.
I tried to view the history of the file but it had appeared that my commit was removed from the history. The people working on the project are not doing any advanced git techniques, its pretty much fetch merge, commit push.
I just don't get why the commit is gone from my history. Shouldn't it be there or when there is a merge conflict and someone resolves and ends up doing a merge commit does that remove history?
We host our repo on bitbucket and I can go there and find my commit with the code I needed to update the file but this seems less then ideal.
We are all new at git and using it for the first time on one of our projects so we are pretty nubish at all this.
git log -p filenamedan.codes 2012-04-04 17:46
git fsck --lost-foundto be able to find your lost commits. Git will never throw away your history without asking you, and even then keeps the references around for awhile before they get garbage collected. It might take some searching but you should be able to get your commits back - Abe Voelker 2012-04-04 18:15
Git's internal structure is that of a DAG, and the branches are just mutable pointers to commits (tags are immutable pointers). Git's log only shows you commits that are reachable by backtracking off of these branches / commit pointers. Somehow, the branch pointer(s) got changed so that your commit became unreachable by backtracking. Something destructive happened in order to cause this, like a rebase.
Since you found your commit, you can see where it fits into the tree by doing this:
git checkout -b temp_branch git reset --hard <lost-commit-sha1> gitk --all
temp_branch is now pointing at your commit and you can see what happened by looking at the DAG.
To answer your question: Someone rewrote the branch history. There's no other way to lose pushed commits.
Solutions to avoid this: restrict non-fast-forward push to most developers and training.