Retrieve commit ids after/since a specific commit id

I am trying to get the list of all commit ids after/since a certain commit id, is there a git command..?

git log --pretty=format:"%H" --since=2014-05-04 would print all the commit-ids since 2014-05-04, similarly is there a command that could print all the commit ids after a certain commit-id?

3 answers

1 accepted

thanks Chris, yes I used the timestamp

m=`git show -s --format=%cD $COMMITID`

git log --pretty=format:"%H" --since="$m"

1 vote
Chris Fuller Atlassian Team Jun 08, 2014
git log --pretty=format:"%H" 123456..

or more briefly

git rev-list 123456..

If you want that commit to be included as well, use 123456^..

Chris,

May be I didn't put my question properly.

Example:

123456daskkl9

56787skjskdk8

adkasjdka6788

dkajsdklja76678

jkajskldal677889

If I try "git log --pretty=format:"%H" adkasjdka6788"

The out put is

adkasjdka6788

dkajsdklja76678

jkajskldal677889

Instead, what I am looking for is a command that would get the below output using adkasjdka6788 commit id.

123456daskkl9

56787skjskdk8

Chris Fuller Atlassian Team Jun 08, 2014

Consider if your commit history looks like this:

May 6          F == HEAD
              / \
May 5        /   E
            /   / \
May 4      /   /   D
          /   /     
May 3    C   /
         |  /
May 2    | B
         |/
May 1    A

So what's the difference between C and F/HEAD here? C only has A as an ancestor, but F also has B, D, and E as its ancestors (and C as well). So if I say git log C..F, it is going to tell me about what these differences are -- that is, it will tell me about B, D, E, and F.

If I say --since=2014-05-03, this is a very different question. It would have told me about the entire history, but I have excluded the things before May 3. This means it will tell me about C, D, E, and F.

Without the --since, how would git know that you want it to list D but don't want it to list B? Even if you followed a shortest path, what that would get you is directly from C to F, with D and E omitted as well. The date is the *only* reason that B didn't get listed by --since, and this is very misleading.

If this is really really really what you want, it amounts to getting the timestamp of the commit and then using --since with that timestamp. As far as I can tell, there is no intrinsic support for that. This is probably a good thing, because what that tells you is misleading.

You can use:

git log --pretty=format:"%H" commit-id..HEAD

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 06, 2018 in Bitbucket

Do you use Bitbucket Cloud and Jira Cloud? If so, let us know!

Hi Community, I'm Julia and I'm on the Jira Software Cloud marketing team!  We're looking for companies or teams using Bitbucket Cloud and Jira Software Cloud. If your team fits the t...

143 views 6 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you