How to list commits since certain commit?

Git

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

git log <hash>..

Is the least amount of typing. Omitting "HEAD" assumes that's what you meant. Rev-list would work too.

Solution 3 - Git

You can run the following git command from the shell:

git log --pretty=oneline commit-id...HEAD

Solution 4 - Git

Assuming that by "commit number", you mean commit hash:

git log <commit-hash>..HEAD

Solution 5 - Git

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>.

Solution 6 - Git

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionehftwelveView Question on Stackoverflow
Solution 1 - GitmanojldsView Answer on Stackoverflow
Solution 2 - GitAdam DymitrukView Answer on Stackoverflow
Solution 3 - GitMatthieuView Answer on Stackoverflow
Solution 4 - GithammarView Answer on Stackoverflow
Solution 5 - GitMatthew HineaView Answer on Stackoverflow
Solution 6 - GitDavid MannView Answer on Stackoverflow