Retrieving a file in git that was deleted and committed
- From
- biswaranjan panda <biswaranjan.nitrkl@gmail.com>
- Date
- Dec 7, 2018, 06:49 UTC
- Message-ID
- <CADHAf1Y_d=-9By4jC2xd+BmWJgfGmBNUr=uSuQtfuHDrarN4kw@mail.gmail.com>
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.
One way is to checkout a separate branch B where the file is present. Then checkout A. Then do git checkout B -- path_to_file
While this does gets the file back, the file shows up as a new file to be committed. Once I commit it, git blame doesn't show the old history for the file.
I would appreciate if anyone knows how to preserve git blame history.