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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:00:19+00:00 2026-06-15T04:00:19+00:00

The git command git log –format=’%H’ –follow — foo.txt will give you the series

  • 0

The git command

git log --format='%H' --follow -- foo.txt

will give you the series of commits that touch foo.txt, following it across renames.

I’m wondering if there’s a git log command that will also print the corresponding historical file name beside each commit.

It would be something like this, where we can interpret '%F' to be the (actually non-existent) placeholder for filename.

git log --format='%H %F' --follow -- foo.txt

I know this could be accomplished with

git log --format='%H' --follow --numstat -- foo.txt

but the output is not ideal since it requires some non-trivial parsing; each commit is strewn across multiple lines, and you’ll still need to parse the file rename syntax ("bar.txt => foo.txt") to find what you’re looking for.

  • 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-06-15T04:00:20+00:00Added an answer on June 15, 2026 at 4:00 am

    You can simplify it a little bit like this:

    git log --format='%H' --name-only --follow -- README.md
    

    which will give you output kind of like this

    621175c4998dfda8da
    
    README.md
    d0d6ef0a3d22269b96
    
    README.md
    

    which should be a little easier to parse. For instance you can use a sentinel and sed out the newlines like this:

    git log --format='%H%%' --name-only --follow -- README.md | sed ':a;N;$!ba;s/%\n\n/ /g'
    

    which should give you the hash and the filename on the same line:

    621175c4998dfda8da README.md
    d0d6ef0a3d22269b96 README.md
    

    For info on the sed invocation, see How can I replace a newline (\n) using sed? which has the answer I based that bit on.

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

Sidebar

Related Questions

I'm looking for a command in git-svn that will show me the changes I
Currently I want to run a batch file that fires the command git log
Running command manually: git log --pretty=format:%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s --date=short Using Bash 6bb9849 2012-08-05
I am trying to execute a command in Node: cd /www/foo/ && /path/to/git/bin/git.exe config
I have a git command that I run to display my logs. It mostly
When I run the command: git log --after=21/9/2012 It seems to have a hidden
I read a similar question about this that suggested using git log --graph --all
When looking at the latest git commits, I know you can do git log
I'd like to use the git log command to extract the list of changes
I can see the text based graph running the command : git log --graph

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.