tags:

views:

69

answers:

2

We've got a repository that has only a master branch (for the purpose of this discussion). Somehow we've got to a situation where a developer has merged his local master and pushed and managed to lose other commits.

The situation is that for a few commits, if we run git log from the root of the project it shows the commit. If we pick one of those files and run git log it doesn't show the commit in the log. The changes in that commit aren't reflected in a checkout of the head either.

Does anyone have any ideas how can this situation occur and how can we stop it happening again?

+1  A: 

If you run

$ git log file

it would display all commits starting from current branch (which might be different: check out "git branch" output of both are on the same branch), but only those commits which have changes which affects given path. Even if you don't have any other branches, you might be on detached HEAD i.e on unnamed branch.

Check also "git show" or "git whatchanged" (or "git show master") if files are truly changed.
Use "git show --cc" or "git show --raw --abbrev" if you want to check merge commit.

For recovery you can use "git reflog" / "git log -g".

Jakub Narębski
+1  A: 

Sounds like maybe the changes to the files where lost in the local merge done by the developer, possibly while resolving conflicts before committing the merge.

You should try this command in the project root directory:

git log --stat -c

Look at which files were changed in each commit, and check if all these changes are included in the merge.

Ropez