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

  • Home
  • SEARCH
  • 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 8896521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:05:50+00:00 2026-06-15T00:05:50+00:00

Say I have a file foo.js that was committed some time ago. I would

  • 0

Say I have a file foo.js that was committed some time ago. I would like to
simply find the commit where this file was first added.

After reading the answers and my own tinkering, this works for me

git log --follow --diff-filter=A --find-renames=40% -- foo.js
  • 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-15T00:05:52+00:00Added an answer on June 15, 2026 at 12:05 am

    Here’s simpler, "pure Git" way to do it, with no pipeline needed:

    git log --diff-filter=A -- foo.js
    

    Check the documentation. You can do the same thing for Deleted, Modified, etc.

    https://git-scm.com/docs/git-log#Documentation/git-log.txt—diff-filterACDMRTUXB82308203

    I have a handy alias for this, because I always forget it:

    git config --global alias.whatadded "log --diff-filter=A"
    

    This makes it as simple as:

    git whatadded -- foo.js
    

    The below one liner will recursively search through sub directories of the $PWD for foo.js without having to supply an absolute or relative path to the file, nor will the file need to be in the same directory as the $PWD

    git log --diff-filter=A -- **foo.js
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now I have an XSD file (e.g. FOO_SCHEMA.xsd) that looks something like this: <xs:schema
Let's say I have a foo.exe file that I want to use it from
I have a file in this structure: 009/foo/bar/hi23123/foo/bar231123/foo/bar/yo232131 What i need is to find
say i have a file /var/www/foo/test.php how do i find out it's path from
Let's say I have a single file, foo.txt, that I want to manage with
Let's say you have a first.sh file in a directory: /home/userbob/scripts/foo/. Basically I would
I have this js file serving from some domain say foobar.com at http://foobar.com/static/js/main.js: $(document).ready(function()
Let's say I have a namespace like that: var myNamespace = { foo: function()
I have some code, say in Foo.scala that compiles readily with scalac , but
Let's say I have a really large file foo.txt and I want to iterate

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.