Try gitk --all
, which will display all branches and tags in your repository.
By default, you're getting something like just the current branch's ancestry.
Question
I have been learning git by playing with its commands and reading stuff. Here is what I can see, I am expecting a graph similar to what I did on the right.
This is confusing, How should the tree look like because I cannot see my other commits? Why can't I see my commits?
Here is what I did:
c08b318
Commited a file called README.md and pushed to mastersomethingnew
643f1b0
modified README.md on somethingnew
branch then commit the modified file1029180
and ad34cc2
somethingnew
created a new file called NewFile.txt and commited the file a526cd9
Solution
Try gitk --all
, which will display all branches and tags in your repository.
By default, you're getting something like just the current branch's ancestry.
OTHER TIPS
Git commit logs are local to the branch, so until a merge happens here - you won't see that commit in your visual log unless you have that branch checked out.
spiders-iMac:git-practice david$ git checkout master
spiders-iMac:git-practice david$ git log --oneline
f1aa76b Contents added to FileA
3c5a4fc Initial commit on master
spiders-iMac:git-practice david$ git checkout somethingnew
Switched to branch 'somethingnew'
spiders-iMac:git-practice david$ git log --oneline
187cd79 Merge branch 'master' into somethingnew
f1aa76b Contents added to FileA
a8fe187 Added FileB on branch somethingnew
3c5a4fc Initial commit on master
spiders-iMac:git-practice david$ git reflog
187cd79 HEAD@{0}: checkout: moving from master to somethingnew
f1aa76b HEAD@{1}: checkout: moving from somethingnew to master
187cd79 HEAD@{2}: checkout: moving from master to somethingnew
f1aa76b HEAD@{3}: checkout: moving from somethingnew to master
187cd79 HEAD@{4}: merge master: Merge made by the 'recursive' strategy.
a8fe187 HEAD@{5}: checkout: moving from master to somethingnew
f1aa76b HEAD@{6}: commit: Contents added to FileA
3c5a4fc HEAD@{7}: checkout: moving from somethingnew to master
a8fe187 HEAD@{8}: commit: Added FileB on branch somethingnew
3c5a4fc HEAD@{9}: checkout: moving from master to somethingnew
3c5a4fc HEAD@{10}: commit (initial): Initial commit on master
spiders-iMac:git-practice david$