git 的 pull、fetch、merge
1.pull = fetch + merge
In the simplest terms, git pull
does a git fetch
followed by a git merge
.
You can do a git fetch
at any time to update your remote-tracking branches under refs/remotes/<remote>/
. This operation never
changes any of your own local branches under refs/heads
, and is safe to do without changing your working copy. I have even heard
of people running git fetch
periodically in a cron job in the background (although I wouldn't recommend doing this).
A git pull
is what you would do to bring a local branch up-to-date with its remote version, while also updating your other
remote-tracking branches.
2. merge VS rebase
2.1、merge命令
把origin分支上的修改拉下来并且和你的修改合并;产生一个合并的提交(merge commit):
2.2、rebase命令
把你的分支里的每个提交(commit)取消掉,并且把它们临时保存为补丁(patch)(.git/rebase目录),然后把你的分支更新到最新的origin分支,
最后把保存的这些补丁应用到你的分支上。在rebase的过程中,也许会出现冲突(conflict),Git会停止rebase并会让你去解决 冲突;在解决完冲突后,
用"git-add"命令去更新这些内容的索引(index), 然后,你无需执行 git-commit,只要执行:
$ git rebase --continue
这样git会继续应用(apply)余下的补丁。在任何时候,你可以用--abort
参数来终止rebase的行动,你的分支会回到rebase开始前的状态。
$ git rebase --abort
3. git merge VS git merge --no-ff
git merge 在没有冲突的时候不会生成新的commit。
如果想在没有冲突的情况下也自动生成一个commit,记录此次合并就可以用:git merge --no-ff
命令。
最新文章
- Oracle用法、函数备忘记录
- 浅谈JS之AJAX
- 跨域API
- 软删除脏数据job笔记
- WPFのInkCanvas作为蒙版透明笔迹不透明
- Heartbeat+LVS构建高可用负载均衡集群
- Java实现Socket5代理服务器
- Android中的TextView实现多行显示省略号
- Python操作IHTMLDocument2用于自动化测试
- 用 Google 挖掘赚钱思路
- 制作Windows服务项目详细攻略
- 开源纯C#工控网关+组态软件(九)定制Visual Studio
- 一篇关于Asp.Net Model验证响应消息的问题处理
- Python学习(十六)—— 数据库
- Elasticsearch索引mapping的写入、查看与修改(转)
- GoldenGate 12.3 MA架构介绍系列(5) - 静默安装
- python opencv show图片,debug技巧
- 最全的前端Git基础命令,看完保证你会!
- 获取docker容器的ip地址
- JavaScript判断值是否是NaN