Skip to content

Commit d682419

Browse files
author
Michael Friedrich
committed
Update the purpose of reset --hard and explain how to undo it with the ref log
1 parent abd2177 commit d682419

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

day1/03_Basics/03_Changes.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ manually move the file, you will need to rm and add it again.
2525
* `git reset`
2626
* Reset files added to the staging index.
2727
* Reset and drop commits
28-
* `--soft` keeps the changes (default), `--hard` removes them indefinitely.
28+
* `--soft` keeps the changes (default), `--hard` removes them.
2929
* `git rm`
3030
* Remove the file(s) from working tree and Git repository.
3131
* Note that file(s) will be visible in Git history, and can be restored from it.
@@ -34,7 +34,12 @@ manually move the file, you will need to rm and add it again.
3434
3535
****
3636
37-
`git reset` resets files added to the staging index.
37+
`git reset` resets files added to the staging index. You can also use it to
38+
reset commits from the history.
39+
40+
Hint: If you are using a `--hard` reset, you can still undo the change
41+
with the help of the ref log where git stores "meta" information about
42+
any change: `git reset --hard HEAD@{1}`.
3843
3944
`git rm` removes the file from the working tree and also from the git index.
4045

day2/01_Workflows/02_Centralized.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ The last parameter specifies the target directory `training2`.
199199
* Objective:
200200
* Rebase your local history with the remote repository
201201
* Steps:
202-
* Reset the local history by 2 commits with `git reset --hard HEAD~2`
202+
* Simulate two commits in the past: `git reset --hard HEAD~2`
203203
* Update and commit README.md
204204
* Fetch remote and compare with `git diff origin/master`
205205
* Rebase with `git rebase origin/master`
@@ -237,7 +237,7 @@ instead of generating a merge commit.
237237
****
238238
239239
* Change into `$HOME/training`
240-
* Reset the local history by 2 commits with `git reset --hard HEAD~2`
240+
* Simulate two commits in the past: `git reset --hard HEAD~2`
241241
* Update and commit README.md
242242
* Fetch the remote repository and use `git diff origin/master` to compare the changes
243243
* Rebase the master branch against the remote master branch with `git rebase origin/master`
@@ -252,7 +252,10 @@ instead of generating a merge commit.
252252
253253
****
254254
255-
### Reset the history by 2 commits
255+
### Simulate two commits in the past
256+
257+
This is just for testing the rebase laster on with different commit history
258+
branches. Commits can be reset from the history with the following command:
256259
257260
@@@ Sh
258261
$ git reset --hard HEAD~2

0 commit comments

Comments
 (0)