You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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`.
14
+
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:
16
+
17
+
```shell
18
+
## branch develop
19
+
git rebase master
20
+
get checkout master
21
+
## 用于将 `master` 上的 HEAD 移动到最新的 commit
22
+
get merge develop
23
+
```
24
+
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`.
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
+
55
+
## Reset
56
+
57
+
If you want to delete the last commit, you can do like this:
58
+
59
+
```shell
60
+
git reset --hard HEAD^
61
+
```
62
+
But this command doesn't delete the commit, it just reset the HEAD and the right branch the HEAD directing.
0 commit comments