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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:01:37+00:00 2026-05-11T03:01:37+00:00

I added a file to the index with: git add somefile.txt I then got

  • 0

I added a file to the index with:

git add somefile.txt 

I then got the SHA1 for this file with:

git hash-object somefile.txt 

I now have a SHA1 and I would like to retrieve the filename of the object in the index using the SHA1.

git show 5a5bf28dcd7944991944cc5076c7525439830122 

This command returns the file contents but not the name of the file.

How do I get the full filename and path back from the SHA1?

  • 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. 2026-05-11T03:01:38+00:00Added an answer on May 11, 2026 at 3:01 am

    There’s no such direct mapping in git as the name of the file is part of the tree object that contains the file, not of the blob object that is the file’s contents.

    It’s not a usual operation to want to retrieve a file name from a SHA1 hash so perhaps you could expand on a real world use case for it?

    If you’re looking at current files (i.e. the HEAD commit) you can try the following.

    git ls-tree -r HEAD | grep <SHA1> 

    If you want to find the contents in previous commits you’ll need to do something more like this.

    git rev-list <commit-list> | \ xargs -n1 -iX sh -c 'git ls-tree -r X | grep <SHA1> && echo X' 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've added a file to the 'index' with: git add myfile.java How do I
I have an already initialized Git repository that I added a .gitignore file to.
i have added google admob jar, have added jar file to builtpath and also
This is an odd one. I added a file to a project, thought I
What's wrong with sqlite 3 ? I have just added libsqlite3 file to my
I added a text file to my solution in VS2010 and called it test.txt.
I have added an HTML file to my solution in VS2010. How do you
I've added as wsdl file using the add servece reference dialog in vs2008. MyService
i made an .xib file and added my buttons and labels. Then I created
Situation: Edit files Add files to the index with git add (these files are

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.