Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git log range revision including the range edges

Tags:

git

git-log

I know that this type of questions is addressed in a lot of Q/A, I have studied them but actually I did not found a way to get the what I want.

I am looking for the git logs between two hashes including the logs of hashes used in the range.

From looking to the docs and other Q/A in SO I have found that it is achievable this way:

git log oldest...Newest

But this does not return the log of oldest is excluded.

For example in this repo https://github.com/galniv/jira-git-helper/commits/master

I want the logs between 52209d3738f80e49c724502503d6a72c1e24e6bc as the oldest and 5456f8cecc5ef5cef5abc1f820a4f044e2153734 as the newest.

The result of git log 52209d3738f80e49c724502503d6a72c1e24e6bc...5456f8cecc5ef5cef5abc1f820a4f044e2153734 returns only two logs instead of 3 :

commit 5456f8cecc5ef5cef5abc1f820a4f044e2153734
Author: Gal Niv <[email protected]>
Date:   Tue Mar 21 15:33:55 2017 -0400

    Update README.md

commit a4c184ecc7fb4c50705c0ac90c94752a31ce7251
Author: Gal Niv <[email protected]>
Date:   Tue Mar 21 11:48:30 2017 -0400

    Remove console.log, display current branch name

How to include the log of the oldest hash?

like image 857
Master Mind Avatar asked Mar 21 '17 20:03

Master Mind


People also ask

How do I make my git log pretty?

A simple fix is to pass the --pretty=oneline parameter, which makes it all fit on a single line. It's taking up less space, but missing crucial information like the date of the commit. There are longer versions of that same --pretty parameter. In fact, it allows you to specify all the fields you want in the output.

How do I limit a git log?

By Amount. The most basic filtering option for git log is to limit the number of commits that are displayed. When you're only interested in the last few commits, this saves you the trouble of viewing all the commits in a page. You can limit git log 's output by including the - option.

What is a revision in git?

So "revision" refers to the id you can use as a parameter to reference an object in git (usually a commit). HEAD@{5 minutes ago} is a revision which reference the commit present 5 minutes ago.


1 Answers

If there's no merge-commit involved, I'd use the ~:

git log old-rev~1..new-rev

That should be enough.

like image 73
eftshift0 Avatar answered Sep 20 '22 02:09

eftshift0