Skip to content

Commit 6f36326

Browse files
author
danc1ngSean
committed
更新文件 git-en.md
1 parent 03bbcd8 commit 6f36326

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

Git/git-en.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,52 @@ After using `rebase`, the commits from `decelop` will be moved to the third `c
1010

1111
![](https://user-gold-cdn.xitu.io/2018/4/23/162f11cc2cb8b332?w=505&h=563&f=png&s=26514)
1212

13-
Compare with `merge`, the result of `rebase` is very clear with a single flow. But if there is any conflict, you'll be in troule to solving them. You have to solve them one by one , while you only need to solve them once if using `merge`.
13+
Compare with `merge`, the result of `rebase` is very clear with a single flow. But if there is any conflict, you'll be in troule to solving them. You have to solve them one by one , while you only need to solve them one-time if using `merge`.
1414

15+
You should use `rebase` on the local branchs which need be rebased. If you need to `rebase` the `develop` to the `master`, you should do as follows:
1516

17+
```shell
18+
## branch develop
19+
git rebase master
20+
get checkout master
21+
## 用于将 `master` 上的 HEAD 移动到最新的 commit
22+
get merge develop
23+
```
1624

25+
## stash
26+
27+
Use `git stash` to save the current state of the working directory while you want to fix a temporary bug in development, if you don't want to use `commit`.
28+
29+
```shell
30+
git stash
31+
```
32+
This command can record the current state of the working directory, if you want to recover it, you can do like this:
33+
34+
```shell
35+
git stash pop
36+
```
37+
then you'll back to the exactly state before.
38+
39+
## reflog
40+
41+
This command will show you the records of HEAD's trace. If you delete a branch by mistake, you can examine the hashs of HEAD by using `reflog`.
42+
43+
![](https://user-gold-cdn.xitu.io/2018/4/23/162f14df98ce3d83?w=950&h=118&f=png&s=77151)
44+
45+
According to the picture, the last movement of HEAD is just after `merge`, and then the `new` branch was deleted, so we can get the branch back by the following command:
46+
47+
```shell
48+
git checkout 37d9aca
49+
git checkout -b new
50+
```
51+
52+
PS:`reflog` is time-bound, it can only record the state over a period of time.
53+
54+
## Reset
55+
56+
If you want to delete the last commit, you can do like this:
57+
58+
```shell
59+
git reset --hard HEAD^
60+
```
61+
But this command doesn't delete the commit, it just reset the HEAD and the right branch the HEAD directing.

0 commit comments

Comments
 (0)