Skip to content

Commit 022274a

Browse files
committed
add how to recover deleted files section
1 parent 805e6a3 commit 022274a

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- [Backing it up online](#backing-it-up-online)
3636
- [Oops! I turned my home folder into a datalad dataset... 🙈](#oops-i-turned-my-home-folder-into-a-datalad-dataset-)
3737
- [🚨 Under the hood: the `.git` folder 🚨](#-under-the-hood-the-git-folder-)
38+
- [Oops! I accidentaly deleted some files. How can I bring them back?](#oops-i-accidentaly-deleted-some-files-how-can-i-bring-them-back)
3839
- [Useful tips](#useful-tips)
3940
- [Useful links](#useful-links)
4041

@@ -1019,7 +1020,7 @@ Grab a coffee and look at that progress bar go! 🚀
10191020
10201021
> **It happened so quickly!** `#TrueStory`
10211022
1022-
🚨 DON'T TRY THIS AT HOME 🚨
1023+
🚨 DON'T TRY THIS AT $HOME 🚨 ([pun intended](https://xkcd.com/559/))
10231024
10241025
```bash
10251026
# when not given any argument
@@ -1061,6 +1062,43 @@ otherwise you will lose the data.
10611062
If you want an hour long deep dive on the content of the `.git` folder,
10621063
[check this video](https://www.youtube.com/watch?v=gdY_RpY2oyU).
10631064
1065+
<hr>
1066+
<br>
1067+
1068+
## Oops! I accidentaly deleted some files. How can I bring them back?
1069+
1070+
If you deleted some files but have not yet saved those changes, there is an easy
1071+
way to bring them back.
1072+
1073+
In case you don't remember type `git status` and it should show a listing of
1074+
file changes including deletion, like the example below.
1075+
1076+
**Example output**
1077+
1078+
```
1079+
On branch master
1080+
Your branch is up to date with 'origin/master'.
1081+
1082+
Changes not staged for commit:
1083+
(use "git add/rm <file>..." to update what will be committed)
1084+
(use "git restore <file>..." to discard changes in working directory)
1085+
modified: README.md
1086+
deleted: images/use_the_force.jpg
1087+
1088+
no changes added to commit (use "git add" and/or "git commit -a")
1089+
```
1090+
1091+
A lot of git commands give you hint on what to type to do certain things.
1092+
1093+
Here it tells you that undo this deletion I would have to type:
1094+
1095+
```bash
1096+
git restore images/use_the_force.jpg
1097+
```
1098+
1099+
<hr>
1100+
<br>
1101+
10641102
## Useful tips
10651103
10661104
If you don't remember the specifics of a command, type the name of that command

0 commit comments

Comments
 (0)