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 4041224
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:51:13+00:00 2026-05-20T12:51:13+00:00

I have a Git project which has a long history. I want to show

  • 0

I have a Git project which has a long history. I want to show the first commit.

How do I do this?

  • 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-20T12:51:14+00:00Added an answer on May 20, 2026 at 12:51 pm

    Short answer

    git rev-list --max-parents=0 HEAD
    

    (from tiho’s comment. As Chris Johnsen notices, --max-parents was introduced after this answer was posted.)

    Explanation

    Technically, there may be more than one root commit. This happens when multiple previously independent histories are merged together. It is common when a project is integrated via a subtree merge.

    The git.git repository has six root commits in its history graph (one each for Linus’s initial commit, gitk, some initially separate tools, git-gui, gitweb, and git-p4). In this case, we know that e83c516 is the one we are probably interested in. It is both the earliest commit and a root commit.

    It is not so simple in the general case.

    Imagine that libfoo has been in development for a while and keeps its history in a Git repository (libfoo.git). Independently, the “bar” project has also been under development (in bar.git), but not for as long libfoo (the commit with the earliest date in libfoo.git has a date that precedes the commit with the earliest date in bar.git). At some point the developers of “bar” decide to incorporate libfoo into their project by using a subtree merge. Prior to this merge it might have been trivial to determine the “first” commit in bar.git (there was probably only one root commit). After the merge, however, there are multiple root commits and the earliest root commit actually comes from the history of libfoo, not “bar”.

    You can find all the root commits of the history DAG like this:

    git rev-list --max-parents=0 HEAD
    

    For the record, if --max-parents weren’t available, this does also work:

    git rev-list --parents HEAD | egrep "^[a-f0-9]{40}$"
    

    If you have useful tags in place, then git name-rev might give you a quick overview of the history:

    git rev-list --parents HEAD | egrep "^[a-f0-9]{40}$" | git name-rev --stdin
    

    Bonus

    Use this often? Hard to remember? Add a git alias for quick access

    git config --global alias.first "rev-list --max-parents=0 HEAD"
    

    Now you can simply do

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

Sidebar

Related Questions

We have a git project which has quite a big history. Specifically, early in
I have a git project which is only local, and only has a master
I have a large-ish project that I'm working on which uses git as the
I have a git repository (covering more or less project history) and separate sources
I have a Git repository, which for my own reasons I want to manage
I have a project in git. It has a couple of submodules. Without going
I am using git for a large legacy project which has two branches -
I have a project in SVN which has a plugins folder. Several of the
I have a rails project deployed on heroku which has only a production environment.
I have a maven multi-modules project which has a depth of around 5 levels.

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.