How do I find and restore a deleted file in a Git repository?
Asked Answered
E

30

3205

Say I'm in a Git repository. I delete a file and commit that change. I continue working and make some more commits. Then, I discover that I need to restore that file after deleting it.

I know I can checkout a file using git checkout <commit> -- filename.txt, but I don't know when that file was deleted.

  1. How do I find the commit that deleted a given filename?
  2. How do I restore that file back into my working copy?
Egger answered 4/6, 2009 at 22:40 Comment(7)
note that the previous comment answers the question in the title, not in the body -- that includes finding out when the file was deleted.Egger
To find the commit a file was deleted in: git log --diff-filter=D -- path/to/fileMaskanonge
Related: How do you discard unstaged changes in git?.Lilt
Related: How to locate a deleted file in the commit historyTrashy
Related: how to restore all deleted files at onceExpressman
@hhh does not work, I get error: pathspec './src/main/resources/file' did not match any file(s) known to git.Nerva
@hhh git checkout deletedFile will undelete deletedFile if it's been deleted but that deletion has not yet been staged or committed. That's not what the question here is asking for; this question is about how to restore a file whose deletion was committed many commits ago.Cesaria
L
3526

Find the last commit that affected the given path. As the file isn't in the HEAD commit, that previous commit must have deleted it.

git rev-list -n 1 HEAD -- <file_path>

Then checkout the version at the commit before, using the caret (^) symbol:

git checkout <deleting_commit>^ -- <file_path>

Or in one command, if $file is the file in question.

git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"

If you are using zsh and have the EXTENDED_GLOB option enabled, the caret symbol won't work. You can use ~1 instead.

git checkout $(git rev-list -n 1 HEAD -- "$file")~1 -- "$file"
Lightish answered 11/7, 2009 at 7:12 Comment(21)
The tricky bit is to checkout the commit BEFORE, using the ^ suffix. Thanks.Abbey
For some reason, this won't work in zsh. ± git checkout $(git rev-list -n 1 HEAD "spec/Sporkfile_example.rb")^ -- "spec/Sporkfile_example.rb" zsh: no matches found: b71c152d8f38dcd23ad7600a93f261a7252c59e9^ I switched to bash & it worked fine though.Keep
I had to use git checkout <deleting_commit>^^ -- <file_path> for some reason--maybe a windows command line thingBeaumont
From the windows command line I got an error. error: pathspec <filename> did not match any file(s) known to git.. The solution was to use git bash.Smitty
@Keep zsh has it's own expansion on '^' I believe, but you can use the alternative syntax of '~1': git checkout <deleting-commit>~1 -- <file-path> ~X allows you to specify X commits before the specified commit, so ~1 is the commit before, ~2 is two commits before, etcNadanadab
@Keep You can also escape the ^ with \^Garald
BTW, if you use fish, that command gets broken and needs escapes, or just fire a bash shell.Crepuscular
The window github command client based on Powershell responded with fatal: ambiguous argument <file_path>: unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' The answer of @Robert Munteanu worked for me.Raouf
@Nils Luxton thanks. for some reason the carat notation didn't work for me while on a win7 platform, but tilde did.Beckner
Worth noting that the single line syntax doesn't work under Windows. Since this is a very popular Q&A (and first entry in Google), would suggest updating the answer to say this (+ the ^ replaced with ~1 mentioned above).Thermomotor
What are the double dashes, --, for?Haley
On windows cmd prompt, the ^ character is the escape character! Therefore, on cmd, you have to type ^^ to tell cmd you want a single literal ^ and that your not escaping something else after it. What's happening to many people is that the ^ is followed by a space. So cmd thinks you're escaping the space -- which yields simply a space character. Thus, by the time git gets the cli arguments, it sees SHA1 and not SHA1^. It's really annoying. ~ isn't an escape character, so that's why that still works. (PS. if you think googlers will want this info, please upvote this comment)Titi
thanks a lot, still couldn't understand why we are checking out the parent of the commit? what does it mean to be a parent of a commit?Eurus
what if there were multiple files deleted in the commit, and i want to get them all? just repeat the command multiple times?Curst
@MuhammadBabar The parent of the commit deleting the desired file is the last commit containing that file, thus guaranteed to be the most recent version of that file. The "parent" nomenclature stems from git's structuring of commits into a tree, in which commits are nodes and the commit preceding another commit is the parent node of that child node. (Compsci 101, you haunt me still.)Suborn
For anyone else wondering about the double dashes, --, it's to separate filenames from git options. It's not strictly necassary unless you specify file names that actually do look like git options.Izanami
Beware that you should run this from the root of you repository, becuase otherwise file path won't be recognized. I spend several minutes until I figured out that I'm actually in a subfolder so this is why it doesn't work.Ruttish
Second command throws me an absurd error "unable to create file www/index.php: Permission denied" although I run console as Administrator.Creese
I get "no matches found: COMMITHASH^". The answer below works for me.Tyra
Now I finally understand what the caret is for. I wish all stackoverflow comments had these kind of explanations.Priddy
I wonder who would be able to use git without SO. Mr Bailey would be obviously one of those few individuals. The rest of us will never master these less-than-intuitive git-isms... :-)Chance
A
1041
  1. Get all the commits which have deleted files, as well as the files that were deleted:

    git log --diff-filter=D --summary
    

    Make note of the desired commit hash, e.g. e4e6d4d5e5c59c69f3bd7be2.

  2. Restore the deleted file from one commit prior (~1) to the commit that was determined above (e4e6d4d5e5c59c69f3bd7be2):

    git checkout e4e6d4d5e5c59c69f3bd7be2~1 path/to/file.ext
    

    Note the ~1. The tilde spec will give you the nth grandparent of the named commit.

Auspex answered 4/6, 2009 at 23:10 Comment(6)
the git checkout $commit~1 filename syntax works perfect for individual files, and also works for whole directories. ie: to restore all deleted images in ./images from sha 12345: git checkout 12345~1 images. thanks for this answer!Sideband
@Eugene Shouldn't the commit id be the one before the file was deleted? It seems if you put the commit id which the file was deleted in the git can't find it.Newsboy
If you just need to check file contents: git show $commit~1:$pathKurtz
@Newsboy , that's what ~1 or ^ does: gets the commit before deletionPiranha
@RobertMunteanu I think you made a typo in "tilde spec gets you the nth grand child". The previous is inaccurate, the tilde gets you the nth grand parent instead (ref) From context, it looks like you meant to say grand parent, howeverPiranha
Good catch @MatthewStrasiotto ! Unfortunately I can't edit comments, so this will have to say as it is.Auspex
S
342

To restore all deleted files in a folder:

git ls-files -d | xargs git checkout --
Squall answered 2/12, 2010 at 6:11 Comment(10)
Where do the files get piped to? I see no change.Bringingup
This is probably the easiest method. Its perverted how difficult git has made even the simplest task.Irisirisa
The ls-files sub-command is handy, but doesn't seem to work for files that had been removed with git rm i.e. staged, let alone committed, which is what the OP asked.Auriscope
This worked for restoring the deleted files, but how can I update the files which where changed and show up as M myChangedFile after git checkout?Laureate
@Laureate after a git checkout a file it will will not show as modified. It will go to the last committed state. You cannot restore the modifications which are not yet committed.Squall
@Irisirisa "the simplest task?" It's clearly not. And the proposed solutions are not difficult. The above line is very straightforward. Git needs to be learned, like any other tool.Bicuspid
@RomainValeri - It is 2019. The tools work for me. I do not work for the tools. If learing is required then the design is broken.Irisirisa
@Irisirisa Fair enough. I didn't intend to question your judgement, I'm sorry, I was trying to restore some hope for new learners :-) (but to be fair, only the simplest of tools can be used without learning.)Bicuspid
@RomainValeri , @Irisirisa you're both right. git is nearly unparalleled in its usefulness, while also imfamously complicated to learn. An appreciable proportion of gits learning curve is due to an inconsistent / unintuitive UI. Personally, when I'm learning something difficult, one of the things that gives me reassurance is seeing that other (competent) people also struggled to figure it outPiranha
It does not answer the question. The question was about committed deletions. The answer is about the working tree and indexImam
E
154

If you deleted a file that exists in the latest HEAD commit, you can restore it using:

git checkout HEAD -- path/to/file.ext
Enchanting answered 10/4, 2014 at 0:3 Comment(0)
M
101

If you’re insane, use git-bisect. Here's what to do:

git bisect start
git bisect bad
git bisect good <some commit where you know the file existed>

Now it's time to run the automated test. The shell command '[ -e foo.bar ]' will return 0 if foo.bar exists, and 1 otherwise. The "run" command of git-bisect will use binary search to automatically find the first commit where the test fails. It starts halfway through the range given (from good to bad) and cuts it in half based on the result of the specified test.

git bisect run '[ -e foo.bar ]'

Now you're at the commit which deleted it. From here, you can jump back to the future and use git-revert to undo the change,

git bisect reset
git revert <the offending commit>

or you could go back one commit and manually inspect the damage:

git checkout HEAD^
cp foo.bar /tmp
git bisect reset
cp /tmp/foo.bar .
Megaton answered 4/6, 2009 at 22:46 Comment(5)
Could you elaborate on git bisect run '[ -e foo.bar ]'?Egger
You can also use good and bad manually, if it's something that can't be checked automatically. See the bisect man page.Megaton
@Egger the git bisect run tells Git to automate bisection by running the command following word 'run' where the command must return 0 for a good version (see git help bisect for details). The '[ -e foo.bar ]' is a standard expression for testing if file foo.bar does exists (the implementation is usually in file /usr/bin/[ which is usually hardlinked to /usr/bin/test) and the single quation marks are used to put that all as a single command line argument.Hornwort
Great idea. I tried this approach and it identified a commit prior to deletion, but not the commit that actually deleted the file. And in another test it identified 2 commits prior to the deletion.Names
Insane? Maybe. But bisect is a great way to help find where a bug was introduced and so it's a valuable skill to learn anyway. So although maybe not the 'correct' or most 'correct' way here it's still a good idea and worth a +1 definitely!Cenogenesis
N
82

My new favorite alias, based on bonyiii's answer (upvoted), and my own answer about "Pass an argument to a Git alias command":

git config alias.restore '!f() { git checkout $(git rev-list -n 1 HEAD -- $1)~1 -- $(git diff --name-status $(git rev-list -n 1 HEAD -- $1)~1 | grep '^D' | cut -f 2); }; f'

I have lost a file, deleted by mistake a few commits ago?
Quick:

git restore my_deleted_file

Crisis averted.

Warning, with Git 2.23 (Q3 2019) comes the experimental command named git restore(!).
So rename this alias (as shown below).


Robert Dailey proposes in the comments the following alias:

restore-file = !git checkout $(git rev-list -n 1 HEAD -- "$1")^ -- "$1"

And jegan adds in the comments:

For setting the alias from the command line, I used this command:

git config --global alias.restore "\!git checkout \$(git rev-list -n 1 HEAD -- \"\$1\")^ -- \"\$1\"" 
Nervine answered 17/2, 2013 at 15:33 Comment(15)
This restores the whole commit, not only the requested file.Suavity
Here is my alias, works wonderfully: restore-file = !git checkout $(git rev-list -n 1 HEAD -- "$1")^ -- "$1"Cretic
@RobertDailey That looks great! I have included your alias in the answer for more visibility.Nervine
@resultsway it would be if you have set the git config alias.restore first.Nervine
For setting the alias from the command line, I used this command: git config --global alias.restore "\!git checkout \$(git rev-list -n 1 HEAD -- \"\$1\")^ -- \"\$1\""Stannum
@Stannum Thank you. I have included your comment in the answer for more visibility.Nervine
Expansion of alias 'restore' failed; '!git' is not a git commandKayak
@KarlMorrison In which OS/shell are you typing this?Nervine
Mac (Bash)! Ifyou just put some info so that this is a linux solution, would be nice^^Kayak
@KarlMorrison Not sure, but you can at least edit your git global configuration (git config --global --edit) and put in it the line restore = !git checkout $(git rev-list -n 1 HEAD -- "$1")^ -- "$1"Nervine
This is great. For GUI I can do Github Desktop using right click on the commit and do "revert this commit"Goldy
for the naming convention of aliases I would suggest something that makes it clear they are aliases like alias.alias-restore, alias.al-restore, ...Overbid
@Overbid interesting idea, I never saw it used before for git alias namesNervine
It might be that someone has the great idea to use an alias in a script then that should be eye catching. E.g. 'git restore' feels like an offical git command and for git versions >2.23 like mentioned actually is an official git command. 'git restore-file' also feels like official command for me.Overbid
@Overbid True. I wrote this answer 6 years before git restore/git switch, that I documented in 2019 in https://mcmap.net/q/12203/-39-git-checkout-39-docs-claim-working-tree-will-change-why-are-edits-not-discarded.Nervine
Y
76

If you know the filename, this is an easy way with basic commands:

List all the commits for that file.

git log -- path/to/file

The last commit (topmost) is the one that deleted the file. So you need to restore the second to last commit.

git checkout {second to last commit} -- path/to/file
Yamamoto answered 27/2, 2016 at 1:50 Comment(2)
This is the first solution I've seen that's simple enough that I won't have to come back here to find it next time. Maybe.Terrarium
@Suncat2000 "second to last" means "previous commit to the deletion", same as "next to last". en.wiktionary.org/wiki/penultimate#SynonymsYamamoto
C
31

To restore a deleted and commited file:

git reset HEAD some/path
git checkout -- some/path

It was tested on Git version 1.7.5.4.

Consultant answered 4/7, 2012 at 4:39 Comment(3)
That didn't work for me. After the checkout, I got error: pathspec 'foo' did not match any file(s) known to git. I made sure that the filename was correct. Git version 2.7.0Yamamoto
-1; this is wrong. These commands will undo a deletion that hasn't yet been committed (the first one unstages the deletion, if it's staged, and the second one discards unstaged changes to the file), but you're claiming here that they'll restore a committed deletion of the file, which simply isn't true and will fail with an error like that in @wisbucky's comment above.Cesaria
@MarkAmery Indeed, I think this command worked well for those developers, who didn't made explicit staging for committing for removed files with git add -A, but so the restored file was still in non committed stage.Consultant
M
29

I've got this solution.

  1. Get the id of the commit where the file was deleted using one of the ways below.

    • git log --grep=*word*
    • git log -Sword
    • git log | grep --context=5 *word*
    • git log --stat | grep --context=5 *word* # recommended if you hardly remember anything
  2. You should get something like:

commit bfe68bd117e1091c96d2976c99b3bcc8310bebe7 Author: Alexander Orlov Date: Thu May 12 23:44:27 2011 +0200

replaced deprecated GWT class
- gwtI18nKeySync.sh, an outdated (?, replaced by a Maven goal) I18n generation script

commit 3ea4e3af253ac6fd1691ff6bb89c964f54802302 Author: Alexander Orlov Date: Thu May 12 22:10:22 2011 +0200

3. Now using the commit id bfe68bd117e1091c96d2976c99b3bcc8310bebe7 do:

git checkout bfe68bd117e1091c96d2976c99b3bcc8310bebe7^1 yourDeletedFile.java

As the commit id references the commit where the file was already deleted you need to reference the commit just before bfe68b which you can do by appending ^1. This means: give me the commit just before bfe68b.

Magdalenamagdalene answered 1/3, 2012 at 10:48 Comment(2)
This is the same approach as the accepted answer, but with some more ways to find the deleting commit. I still like the approach taken in the accepted answer, but these are good alternatives. Thanks!Egger
I assume that first checking out the deleted file and then (without changing it) commiting it does not create a copy of the file. Right? (I need to do this with images, and a copies would make the repository bigger)Disunity
B
25

If you only made changes and deleted a file, but not commit it, and now you broke up with your changes

git checkout -- .

but your deleted files did not return, you simply do the following command:

git checkout <file_path>

And presto, your file is back.

Bicarbonate answered 2/9, 2016 at 15:30 Comment(0)
K
20

git undelete path/to/file.ext

  1. Put this in your .bash_profile (or other relevant file that loads when you open a command shell):

    git config --global alias.undelete '!sh -c "git checkout $(git rev-list -n 1 HEAD -- $1)^ -- $1" -'
    
  2. Then use:

    git undelete path/to/file.ext
    

This alias first checks to find the last commit where this file existed, and then does a Git checkout of that file path from that last commit where this file existed. Source.

Knockout answered 8/6, 2017 at 1:13 Comment(0)
C
19

Actually, this question is directly about Git, but somebody like me works with GUI tools like the WebStorm VCS other than knowing about Git CLI commands.

I right click on the path that contains the deleted file, and then go to Git and then click on Show History.

Enter image description here

The VCS tools show all revisions train and I can see all commits and changes of each of them.

Enter image description here

Then I select the commits that my friend delete the PostAd.js file. now see below:

Enter image description here

And now, I can see my desire deleted file. I just double-click on the filename and it recovers.

Enter image description here

I know my answer is not Git commands, but it is fast, reliable and easy for beginner and professional developers. WebStorm VCS tools are awesome and perfect for working with Git and it doesn't need any other plugin or tools.

Catholic answered 24/11, 2018 at 11:12 Comment(2)
If you don't know in which commit the file has been deleted and it happened a while ago you'll spend much time manually looking through commit after commit.Rabaul
This is useful because I don't remember the full path of the file I'm looking for usuallyJohnathon
U
15
git checkout /path/to/deleted.file
Unapproachable answered 25/6, 2013 at 19:40 Comment(2)
This one for my situation (removed unintentionally) was the most straightforward solution.Veraveracious
An explanation would be in order.Magi
M
12

In many cases, it can be useful to use coreutils (grep, sed, etc.) in conjunction with Git. I already know these tools quite well, but Git less so. If I wanted to do a search for a deleted file, I would do the following:

git log --raw | grep -B 30 $'D\t.*deleted_file.c'

When I find the revision/commit:

git checkout <rev>^ -- path/to/refound/deleted_file.c

Just like others have stated before me.

The file will now be restored to the state it had before removal. Remember to re-commit it to the working tree if you want to keep it around.

Myrtlemyrvyn answered 22/10, 2012 at 13:9 Comment(0)
R
7

I had to restore a bunch of deleted files from a specific commit, and I managed it with two commands:

git show <rev> --diff-filter=D --summary --name-only --no-commit-id | xargs git checkout <rev>^ -- 
git show <rev> --diff-filter=D --summary --name-only --no-commit-id | xargs git reset HEAD 

(Note the trailing space on the end of each command.)

The files had been added to the .gitignore file and then cleared with git rm. I needed to restore the files, but then unstage them. I had hundreds of files to restore, and typing things manually for each file as in the other examples was going to be far too slow.

Reata answered 29/11, 2013 at 20:5 Comment(0)
R
7

I had the same question. Without knowing it, I had created a dangling commit.

List dangling commits

git fsck --lost-found

Inspect each dangling commit

git reset --hard <commit id>

My files reappeared when I moved to the dangling commit.

git status for the reason:

“HEAD detached from <commit id where it detached>”

Revest answered 4/1, 2018 at 17:8 Comment(0)
B
7

Find the commit that deleted your file:

git log --diff-filter=D --oneline -- path/to/file | cut -f -d ' '

Sample output:

4711174

As of Git 2.23 there is actually a restore command. It is still experimental but in order to restore something you removed in a commit (4711174 in this case) you can then type:

git restore --source=4711174^ path/to/file

Note the ^ after the commit id as we want to restore something from the commit before the one that deleted the file.

The --source argument tells the restore command where to look for the file(s) to restore and it can be any commit and even the index.

See: git-restore doc for git 2.23.0

Bitty answered 5/9, 2019 at 16:5 Comment(1)
Thanks. My cut command needed different args. MacOS 10.13.6 and Git 2.26 => git log --diff-filter=D --oneline -- path/to/file | cut -d ' ' -f 1Mandalay
T
5

In our case we accidentally deleted files in a commit and some commits later we realized our mistake and wanted to get back all the files that were deleted, but not those that were modified.

Based on Charles Bailey's excellent answer, here is my one-liner:

git co $(git rev-list -n 1 HEAD -- <file_path>)~1 -- $(git diff --name-status $(git rev-list -n 1 HEAD -- <file_path>)~1 head | grep '^D' | cut -f 2)
Tamas answered 2/7, 2012 at 20:52 Comment(0)
E
5
user@bsd:~/work/git$ rm slides.tex
user@bsd:~/work/git$ git pull 
Already up-to-date.
user@bsd:~/work/git$ ls slides.tex
ls: slides.tex: No such file or directory

Restore the deleted file:

user@bsd:~/work/git$ git checkout
D       .slides.tex.swp
D       slides.tex
user@bsd:~/work/git$ git checkout slides.tex 
user@bsd:~/work/git$ ls slides.tex
slides.tex
Erato answered 29/11, 2012 at 16:35 Comment(2)
The question was about restoring a file after it has been deleted and the change has been committed. This answer is about restoring a file which was removed only in the working directory.Zales
That's true, and that was what I was looking for.Lanell
K
5

Plus point: The below methods does work good for the scenario that files/folders got deleted even from your Trash or Recycle bin.

Files/Folders are deleted from working tree but not committed yet:

I. If you have not yet indexed (git add) your changes you can revert content of a directory:

git restore -- path/to/folder_OR_file

II. If the deletion is already indexed, you should reset that first:

git reset -- path/to/folder_OR_file

then perform, git restore path/to/folder_OR_file

Files/Folders are deleted in some commit in the past:

  1. Use git log --diff-filter=D --summary to get details of the commits in which files/folder were deleted;
  2. Use git checkout $commit~1 path/to/folder_OR_file to restore the deleted files/folder. Where $commit is the sha-value of the commit you've found at step 1, e.g. c7578994
Kristof answered 30/5, 2021 at 16:18 Comment(0)
C
4

If you know the commit that deleted the file(s), run this command where <SHA1_deletion> is the commit that deleted the file:

git diff --diff-filter=D --name-only <SHA1_deletion>~1 <SHA1_deletion> | xargs git checkout <SHA1_deletion>~1 --

The part before the pipe lists all the files that were deleted in the commit; they are all checkout from the previous commit to restore them.

Celibate answered 3/12, 2015 at 1:4 Comment(0)
V
4

For the best way to do that, try it.


First, find the commit id of the commit that deleted your file. It will give you a summary of commits which deleted files.

git log --diff-filter=D --summary

git checkout 84sdhfddbdddf~1

Note: 84sdhfddbddd is your commit id

Through this you can easily recover all deleted files.

Voussoir answered 6/3, 2020 at 9:59 Comment(0)
B
3

Simple and precise-

First of all, get a latest stable commit in which you have that file by -

git log 

Say you find $commitid 1234567..., then

git checkout <$commitid> $fileName

This will restore the file version which was in that commit.

Betancourt answered 26/10, 2018 at 6:41 Comment(0)
B
3

This is the easiest solution I found if you want just restore the same file in master:

git checkout master -- path/to/File.java
Breadthways answered 6/10, 2021 at 16:13 Comment(0)
E
2

You could always git revert your commit which deleted the file. (This assumes that the deletion was the only change in the commit.)

> git log
commit 2994bda49cd97ce49099953fc3f76f7d3c35d1d3
Author: Dave <[email protected]>
Date:   Thu May 9 11:11:06 2019 -0700

    deleted readme.md

And if you've continued work, and realized later that you didn't want to commit that deletion commit, you could revert it using:

> git revert 2994bd

Now git log shows:

> git log
Author: Dave <[email protected]>
Date:   Thu May 9 11:17:41 2019 -0700

    Revert "deleted readme"

    This reverts commit 2994bda49cd97ce49099953fc3f76f7d3c35d1d3.

And readme.md has been restored into the repository.

Echoism answered 9/5, 2019 at 18:19 Comment(0)
F
1

If the deletion has not been committed, the command below will restore the deleted file in the working tree.

$ git checkout -- <file>

You can get a list of all the deleted files in the working tree using the command below.

$ git ls-files --deleted

If the deletion has been committed, find the commit where it happened, then recover the file from this commit.

$ git rev-list -n 1 HEAD -- <file>
$ git checkout <commit>^ -- <file>

In case you are looking for the path of the file to recover, the following command will display a summary of all deleted files.

$ git log --diff-filter=D --summary
Foresheet answered 12/2, 2020 at 18:56 Comment(0)
L
0

I also have this problem using the below code to retrieve a previous file to a local directory:

git checkout <file path with name>

The below example is working for me:

git checkout resources/views/usaSchools.blade.php

Litigation answered 2/8, 2019 at 15:42 Comment(0)
T
0

You can checkout deleted files:

git checkout

Output

D       index.html

To restore it:

git restore index.html

If you deleted multi files and you need to restore all use:

git restore .

See Gif image restore files by git

Threw answered 1/5, 2021 at 13:25 Comment(0)
B
-1
$ git log --diff-filter=D --summary  | grep "delete" | sort
Backandforth answered 5/2, 2018 at 1:1 Comment(1)
An explanation would be in order.Magi
W
-1

In order to restore all deleted file with Git, you can also do:

git checkout $(git ls-files --deleted)

Where git ls-files --deleted lists all deleted files and git checkout $(git command) restores the list of files in a parameter.

Winchester answered 2/12, 2019 at 12:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.