Reputation: 3137
Is there anyway to get a list of commits from a given commit number to HEAD?
I know this is possible by the commit date, but I need it by the commit number and I can't seem to find any documentation, or even if this is possible.
Upvotes: 258
Views: 134568
Reputation: 129782
git log <hash>^..
Is the least amount of typing. Omitting "HEAD" assumes that's what you meant. Rev-list would work too.
Upvotes: 132
Reputation: 544
Just adding to the answer for the general case you can get all commits from one commit to another commit. For example lets sayA
is commit hash start and B
is commit hash end then
git rev-list <A>..<B>
for detailed
git log <A>..<B>
Upvotes: 2
Reputation: 10912
Ranges like hash..HEAD
don't seem to reliably yield the result in historical order, and options like --author-date-order
seem to be ignored.
To get all commits historically since a given hash, I have found something like this to be the only correct solution (Bash):
git log --author-date-order --all --reverse --after="$(git show -s --format='%at' COMMIT_HASH)"
Upvotes: 4
Reputation: 2004
As others have said, git log <commit-hash>..HEAD
gets you started. git log <commit-hash>...HEAD
is also suggested. I'm adding this answer because the number of periods can make a huge difference for diffs, so it may be worth understanding for git log
also.
I don't understand it enough to explain it for git log
behavior. For git diff branchA..branchB
, the two-dot operator compares the files etc on branchB's tip to the state of files etc on branchA's tip. The three-dot operator compares the files etc on branchB's tip to the files etc in branchA at the commit where branchB diverged from branchA.
To me, this distinction can be important because three-dot might not show that similar changes were already made by some separate branch that got merged. i.e. the diff on a pull request might not show the current context of a patch to a function, if the function has changed since the branch diverged.
As an aside, GitHub, implicitly, uses a three-dot comparison on Pull Requests. GitHub Enterprise also uses three-dot. As of writing this, there is a way to see how to do a two dot comparison in github on the linked pages.
Upvotes: 2
Reputation: 1931
If anyone here is trying to find out how to LESS through the output of git log
starting at a certain commit, paginating backward, it's as simple as git log <hash>
.
Upvotes: 6
Reputation: 16417
You can run the following git command from the shell:
git log --pretty=oneline commit-id...HEAD
Upvotes: 63
Reputation: 301587
git rev-list <since_hash>..HEAD
or to include the commit:
git rev-list <since_hash>^..HEAD
You can use git log
instead of git rev-list
as well to get additional details.
Upvotes: 291
Reputation: 139930
Assuming that by "commit number", you mean commit hash:
git log <commit-hash>..HEAD
Upvotes: 20