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
Sergey Organov <sorganov@gmail.com>
Date
Dec 10, 2018, 15:12 UTC
Message-ID
<87sgz58lh5.fsf@javad.com>
In-Reply-To
<CADHAf1Y_d=-9By4jC2xd+BmWJgfGmBNUr=uSuQtfuHDrarN4kw@mail.gmail.com>
biswaranjan panda <biswaranjan.nitrkl@gmail.com> writes:
Show 5 quoted lines
> I have the following scenario:
>
> On a branch A, I deleted a file foo.txt and committed the change. Then
> I did a bunch of other changes.
> Now I want to undelete foo.txt.
[...]
> I would appreciate if anyone knows how to preserve git blame history.

Provided you deleted the file by mistake and you didn't yet publish the history, just rewrite the history, fixing the commit that deleted the file. "git rebase -i" is a suitable way to do it.

-- Sergey
Previous: Jeff King
Message 12 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.