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?
How do you jump to the first commit in git? [duplicate]
To go the first commit of the repo, do
git checkout master
git 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 log
you 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)
© 2022 - 2024 — McMap. All rights reserved.