How can I jump to the first every commit in a git repository? Also, is there a way to do it on Github through the website?
Asked
Active
Viewed 2.4k times
1 Answers
48
To go the first commit of the repo, do
git checkout mastergit log --reverse- The first entry in the output is the first commit.
- you can switch to that commit by
git checkout <SHA-1>, where is the SHA of the commit(first one) Also, when you dogit logyou can easily navigate to the last entry to see the first commit.
All this can also be done in single command like git checkout `git rev-list --max-parents=0 HEAD | tail -n 1` which means to switch to the last commit having no parent from the current HEAD
Note: if you used --depth option, you might not be able to see the actual first commit, to avoid this ensure you clone the full repo (without --depth option)
Harshit Garg
- 2,137
- 21
- 23