I can find out how many commits there are with this:
git rev-list HEAD --count
Let's say that returns 123 commits.
How can I find the nth commit out of 123? Note that I am not asking for the nth commit before HEAD. I would like to know the nth commit after the very first commit.
To view the previous commits, use the git log –-oneline command. This provides the commit details.
# open the git config editor $ git config --global --edit # in the alias section, add ... [alias] lastcommit = rev-parse HEAD ... From here on, use git lastcommit to show the last commit's hash.
Viewing a list of the latest commits. If you want to see what's happened recently in your project, you can use git log . This command will output a list of the latest commits in chronological order, with the latest commit first.
`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.
This could be considered ugly but I could not think of a better way
$git log --skip=N --max-count=1
This will show exactly 1 commit, counting back from HEAD by N
. To use this you need to provide a number for N
though. N
is calculated with
N = total-commits - desired-commit-nr
Say git rev-list HEAD --count
returns 10 and you want to view the 3rd commit
$git log --skip=7 --max-count=1
We use 7 because
7 = 10 - 3
total ^ ^ the commit we want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With