Added explanation of HEAD, kept past example

This commit is contained in:
Richard Littauer 2015-05-19 14:12:28 +07:00
parent 6a23217314
commit b0c20c4804
1 changed files with 6 additions and 3 deletions

View File

@ -293,23 +293,26 @@ Create the new branch while remaining on master:
(master)$
```
Find out what the commit hash you want to set your master branch to (`git log` should do the trick). Then reset to that hash. `git push` will make sure that this change is reflected on your remote.
Reset the branch master to the previous commit:
```sh
(master)$ git reset --hard HEAD^
```
`HEAD^` is short for `HEAD^1`. You can reset further through the generations by specifying which `HEAD` to set to.
Alternatively, if you don't want to use `HEAD^`, find out what the commit hash you want to set your master branch to (`git log` should do the trick). Then reset to that hash. `git push` will make sure that this change is reflected on your remote.
For example, if the hash of the commit that your master branch is supposed to be at is `a13b85e`:
```
```sh
(master)$ git reset --hard a13b85e
HEAD is now at a13b85e
```
Checkout the new branch to continue working:
```
```sh
(master)$ git checkout new-branch
```