10 something commits back, I made a change to .gitignore file. Today when I pulled the latest code, my change was not there. So I ran this command:
git log -p .gitignore
And it showed me that the last change to the file was mine. Then I pulled all the commits between now and my commit, and pinpointed the commit that removed my change. Then I took the diff of That commit, and the one before that, and in the diff I could see the change to the file.
But why can’t I see the change through above command? And I don’t even see this change when I use
gitk .gitignore
Also I am wondering, might this happen when I try to see the history of some other file as well?
Maybe change you’re talking about was introduced by merge with another branch? There are different merge strategies, and despite your commit might be chronologically last one, the merge procedure might prefer older commit which complies with the strategy rules.
By default git uses
recursivestrategy which will arrange commits in the order they was created. But maybe in your case merge was done usingoursandheirsstrategy preferring commits from one branch over commits from another. That’s why you might not see what you actually expect.Please visit this Q&A to get more information on strategies.