git status shows that I have 2 commits
# On branch production
# Your branch is ahead of 'origin/production' by 2 commits.
#
but git diff shows nothing
git diff
doesn't, by default, show you anything from previous commits. You should use git log
for that. To show the last two commits, use git log -2
.
To compare commits with each other using diff, the syntax is git diff commit1 commit2
. For example, to show you all the changes that occurred between two commits ago and now, type git diff HEAD^2 HEAD
.
More generally, to show commits present in HEAD, but not origin/production:
git log origin/production..
With filenames information (from How to have git log show filenames like svn log -v ):
git log --stat origin/production..
git log --name-status origin/production..
git log --name-only origin/production..
I always use the following to see my commit tree:
$ gitk
Without arguments git diff
only shows the difference between your actual changes and the actual commit, meaning everything you changed since your last git checkout
or git commit
.