|
35 | 35 | - [Backing it up online](#backing-it-up-online) |
36 | 36 | - [Oops! I turned my home folder into a datalad dataset... 🙈](#oops-i-turned-my-home-folder-into-a-datalad-dataset-) |
37 | 37 | - [🚨 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) |
38 | 39 | - [Useful tips](#useful-tips) |
39 | 40 | - [Useful links](#useful-links) |
40 | 41 |
|
@@ -1019,7 +1020,7 @@ Grab a coffee and look at that progress bar go! 🚀 |
1019 | 1020 |
|
1020 | 1021 | > **It happened so quickly!** `#TrueStory` |
1021 | 1022 |
|
1022 | | -🚨 DON'T TRY THIS AT HOME 🚨 |
| 1023 | +🚨 DON'T TRY THIS AT $HOME 🚨 ([pun intended](https://xkcd.com/559/)) |
1023 | 1024 |
|
1024 | 1025 | ```bash |
1025 | 1026 | # when not given any argument |
@@ -1061,6 +1062,43 @@ otherwise you will lose the data. |
1061 | 1062 | If you want an hour long deep dive on the content of the `.git` folder, |
1062 | 1063 | [check this video](https://www.youtube.com/watch?v=gdY_RpY2oyU). |
1063 | 1064 |
|
| 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 | +
|
1064 | 1102 | ## Useful tips |
1065 | 1103 |
|
1066 | 1104 | If you don't remember the specifics of a command, type the name of that command |
|
0 commit comments