Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7184363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:11:10+00:00 2026-05-28T18:11:10+00:00

Some Git commands take the parent as a revision; others (such as git revert

  • 0

Some Git commands take the parent as a revision; others (such as git revert), as a parent number. How can I get the parents for both cases?

I don’t want to use the graphical log command as that often requires scrolling down a long tree to find the second parent.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:11:11+00:00Added an answer on May 28, 2026 at 6:11 pm

    Simple git log <hash> called for a merge commit shows abbreviated hashes of its parents:

     $ git log -1 395f65d
     commit 395f65d438b13fb1fded88a330dc06c3b0951046
     Merge: 9901923 d28790d
     ...
    

    git outputs parents according to their number: the first (leftmost) hash is for the first parent, and so on.

    If all you want is just the hashes, the two equivalent choices are:

    $ git log --pretty=%P -n 1 <commit>
    $ git show -s --pretty=%P <commit>
    

    git rev-list can also show the parents’ hashes, though it will first list the hash for a commit:

    $ git rev-list --parents -n 1 <commit>
    

    If you want to examine the parents, you can refer to them directly with carats as <commit>^1 and <commit>^2, e.g.:

    git show <commit>^1
    

    This does generalize; for an octopus merge you can refer to the nth parent as <commit>^n. You can refer to all parents with <commit>^@, though this doesn’t work when a single commit is required. Additional suffixes can appear after the nth parent syntax (e.g. <commit>^2^, <commit>^2^@), whereas they cannot after ^@ (<commit>^@^ isn’t valid). For more on this syntax, read the rev-parse man page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some Git commands take commit ranges and one valid syntax is to separate two
When merging topic branch "B" into "A" using git merge , I get some
Subtrees in Git work nicely although some git commands remain to be supported for
When trying to use some of the commands from the Git bundle for TextMate
I've been doing some reading on how both the git merge and git rebase
I'm having a hard time understanding some git/DCVS concepts. Here's what happened: I created
I've been using git for some time now on Windows (with msysGit) and I
I need to make some commits using Git but I would like the timestamp
I found a post-receive hook for Git after some googling that I use to
I am getting 'trailing whitespace' errors trying to commit some files in Git. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.