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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:13:52+00:00 2026-05-24T20:13:52+00:00

$ git init $ echo zero > a $ git add a $ git

  • 0
$ git init
$ echo zero > a
$ git add a
$ git commit -m zero
$ echo other > a
$ git add a
$ git commit -m other
$ echo whatever > a
$ git add a
$ git commit -m whatever

I’m checking out the file as it was when I commited the 2nd time, when the file contained the text other.

$ git checkout HASH_OF_COMMIT_OTHER a
$ cat a
other
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   a
#

What command should I run on a, so that git will tell at which changeset it currently is? In this case I would like it to show me the hash of the 2nd commit, along with the commit message, if possible.

  • 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-24T20:13:52+00:00Added an answer on May 24, 2026 at 8:13 pm

    Once you’ve run the command git checkout HASH_OF_COMMIT_OTHER a, the working tree and the index are updated with the version of a from HASH_OF_COMMIT, but there’s no record preserved of how the file was changed to be in that state. This is part of git’s philosophy of tracking content – it doesn’t matter how the file got into the state it is at a certain commit, it just records the exact content of the files at each one.

    You could certainly write a short script to find all commits that contained a file with exactly that content (and at that path) if you like, but normally one wouldn’t need to.

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

Sidebar

Related Questions

D:\code\gt>git init Initialized empty Git repository in D:/code/gt/.git/ D:\code\gt>echo Zero > a D:\code\gt>git add
I usually do this: git init git add . git commit . And then
How would you accomplish this? mkdir newbuild cd newbuild git init git remote add
If my .gitignore file has tmp\ in it and I do a git add
I have a folder, which I use git init, then, I use git add
I am trying to run this line out of http://docs.heroku.com/quickstart git init But I
After git init , I added and committed a few files, made some changes,
I have a git-cpan-init of a repo which yielded a different root node from
I've tried both of the following: repo init -u git://android.git.kernel.org/platform/manifest.git -b android-2.1 repo init
Git says to use git add to add untracked files to my repo. 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.