Git Update
![](https://img.haomeiwen.com/i3409462/e19dd88c4e68089e.png)
![](https://img.haomeiwen.com/i3409462/f169df8e507a8834.png)
参考一下图解即可:
![](https://img.haomeiwen.com/i3409462/f8c813752f1bfe38.png)
- Merge:The result is identical with that of running git fetch ; git merge or git pull.
- Rebase: The result is identical with that of running git fetch ; git rebase or git pull --rebase.
- Branch Default: This option is to choose the default command for the branch applied. The default command is specified in the branch.<name> section of the .git/config configuration file.
- merge:从指定的
commit
(s
)合并到当前分支的操作(原有分支不删除)- rebase:从指定的
commit
(s
)合并到当前分支的操作(原有分支删除),可将提交文件连接成一个线状- branch default:默认分支被视为存储库中的基本分支, 除非您指定不同的分支, 否则将自动对其发出所有请求和代码提交。
merge
:就是git
的合并代码。远程代码在你push
之前已经被修改了。就需要先merge
。如果没有冲突,就自动合并修改,否则需要逐一合并。
rebase
: 拉下来的代码有冲突,但是不会自动合并。需要你手动合并。
你要知道的第一件事是,git rebase
和git merge
做的事其实是一样的。它们都被设计来将一个分支的更改并入另一个分支,只不过方式有些不同。
当你刚创建了一个专门的分支开发新功能,然后团队中另一个成员在master
分支上添加了新的提交。这就会造成提交历史被Fork
一份,用Git
来协作的开发者应该都清楚。
现在,如果master
中新的提交和你的工作是相关的。为了将新的提交并入你的分支,你有两个选择:merge
或rebase
。
Merge
将feature
分支合并到master
分支最简单的办法就是用下面这些命令:
git checkout master
git merge feature
master
分支中新的合并提交(merge commit
)将两个分支的历史连在了一起。
Merge
好在它是一个安全的操作。现有的分支不会被更改,避免了rebase
潜在的缺点(后面会说)。
Rebase
作为merge
的替代选择,你可以像下面这样将feature
分支并入master
分支:
git checkout master
git rebase feature
它会把整个feature
分支移动到master
分支的后面,有效地把所有master
分支上新的提交并入过来。但是,rebase
为原分支上每一个提交创建一个新的提交,重写了项目历史,并且不会带来合并提交。
Git Pull
![](https://img.haomeiwen.com/i3409462/d3281e99c1bd5035.png)
![](https://img.haomeiwen.com/i3409462/e5f2dc69b8f66c1b.png)
网友评论