We have a situation where sometimes a file in github reverts to a previous version. We only have a master branch. We can see the change in the commit history, and it is the last change that has occurred for that file, but viewing the file in Github and pull / fetch from client tools shows an older version.
One possible symptom is that normally I see this when viewing each commit at the repository level
However, in the case where the file has lost its changes, it looks like this:
And the change made in commit 3 has gone.
So here is what I bet is happening here: either commit 5 has both 3 and 4 as parents (i.e. it is a merge commit), or some descendant of commit 5 is a merge commit, with one of its parents being commit 3. If that is the case, here is what happened: commits 1 and 2 were both on the server and in everyone's local repositories. Someone makes commit 3 and pushes to the server. Someone else (without pulling from the server) makes commits 4 and 5 (and perhaps more). If they try to push, they get a "no fast forward" error, since their repo is out of date. The error suggests that they pull, so they do just that. Now a pull is a fetch and a merge, but in this case, the merge resulted in conflicts, so it was not automatically committed. The person resolves the merge conflicts, but then before committing the merge notices that there are changes (totally unrelated to the conflicts) staged that they did not make. These are the changes from commit 3 that are about to be lost. The person undoes those changes, commits, then pushes.
The reason why you do not see this "botched merge" commit when you view a history of the file in question is that git by default does not include merge commits in a file's history if that file is not different than both
of that commit's parents. In this case, the file is different than commit 3 (because the changes done in commit 3 were undone), but is not different from the other parent. To include this botched merge in the history, use
git log --full-history
The bottom line is that all users of the repository must be made aware that when committing a merge, they must
commit all staged changes, even if they did not make those changes, as those are the changes that are supposed to be merged in from the "other" branch.