How to check the latest commit irrespective of the branch in the git history?
You were very close. The command git log -n 1 --date-order
get the last commit from the current branch. Just add --all
to get commits from all branches:
git log -n 1 --date-order --all
This answer is based on How can I get a list of Git branches, ordered by most recent commit?, whose accepted answer sorts all branches in a Git repo by the latest commit date (i.e. the commit date of the HEAD of each branch):
git branch --sort=-committerdate
Once you find the most recently edited branch, you may simply use git log
to find the SHA-1 of the HEAD commit:
git log some_branch