git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Retrieving a file in git that was deleted and committed

From
Jeff King <peff@peff.net>
Date
Dec 8, 2018, 07:29 UTC
Message-ID
<20181208072915.GA20697@sigill.intra.peff.net>
In-Reply-To
<CADHAf1bH5Aaw3-5WvoHawjXUXL9B-YNvh+AYU1fpGbUe=c0E+A@mail.gmail.com>
On Fri, Dec 07, 2018 at 01:50:57PM -0800, biswaranjan panda wrote:
Show 5 quoted lines
> Thanks Jeff and Bryan! However, I am curious that if there were a way
> to tell git blame to skip a commit (the one which added the file again
> and maybe the one which deleted it originally) while it walks back
> through history, then it should just get back the
> entire history right ?
Not easily. ;)

You can feed a set of revisions to git-blame with the "-S" option, but I don't offhand know how it handles diffs (I think it would have to still diff each commit against its parent, since history is non-linear, and a list is inherently linear). You might want to experiment with that.

Other than that, you can play with git-replace to produce a fake history, as if the deletion never happened. But note that will affect all commands, not just one particular blame. It might be a neat way to play with blame, but I doubt I'd leave the replacement in place in the long term.

-Peff
Previous: biswaranjan pandaNext: biswaranjan panda
Message 7 of 12 in “Retrieving a file in git that was deleted and committed”
  1. biswaranjan pandaDec 7, 2018
  2. Bryan TurnerDec 7, 2018
  3. biswaranjan pandaDec 7, 2018
  4. Jeff KingDec 7, 2018
  5. Bryan TurnerDec 7, 2018
  6. biswaranjan pandaDec 7, 2018
  7. Jeff KingDec 8, 2018
  8. biswaranjan pandaDec 9, 2018
  9. Junio C HamanoDec 11, 2018
  10. Elijah NewrenDec 10, 2018
  11. Jeff KingDec 11, 2018
  12. Sergey OrganovDec 10, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.