当前回答
git-pull - Fetch from and merge with another repository or a local branch SYNOPSIS git pull … DESCRIPTION Runs git-fetch with the given parameters, and calls git-merge to merge the retrieved head(s) into the current branch. With --rebase, calls git-rebase instead of git-merge. Note that you can use . (current directory) as the <repository> to pull from the local repository — this is useful when merging local branches into the current branch. Also note that options meant for git-pull itself and underlying git-merge must be given before the options meant for git-fetch.
如果你想要合并历史,你会拉拉, 你会拉拉,你会拉拉拉,如果你只是"想要的cotz" ,因为有人一直在标记 一些文章在这里。
其他回答
Git允许在较新的承诺之后适用按时间顺序排列的旧承诺。 因此,存放库之间转移承诺的行为分为两步:
正在从远程分支复制新承诺, 复制本地副本中的此远程分支 。
(收回业务)
master@remote >> remote/origin/master@local
整合对地方分支机构的新承诺
(内购外业务)
remote/origin/master@local >> master@local
第二步有两种方法,你可以:
- 在上一个共同祖先之后,将本地分支叉到叉口,并添加与本地仓库独特的承诺平行的新承诺,通过合并承诺最终完成,关闭叉口。
- 在上一个共同祖先后插入新承诺,并重新应用本地仓库独有的承诺。
内git
术语术语,第1步是git fetch
,第2步是git merge
或git rebase
git pull
是git fetch
和git merge
您可以从远程仓库获取, 查看差异, 然后拉动或合并 。
这是被称作远程仓库的示例origin
和支派,和支派,master
跟踪远程分支origin/master
:
git checkout master
git fetch
git diff origin/master
git rebase origin master
Git使用两个命令从远程到本地获取最新版本的分支 :
git 获取: Git 将会从远程获取最新版本到本地版本, 但不会自动合并 。
git fetch origin master
git log -p master..origin/master
git merge origin/master
以上命令意味着从远程到源主分支下载主分支的最新版本。 然后比较本地主分支和源主分支。 最后, 合并 。
Git将从远程获取最新版本, 并合并到本地 。
git pull origin master
以上命令相当于
git fetch
和git merge
在实践中,git fetch
也许更安全,因为在合并之前,我们可以看到变化,决定是否合并。
实际上 Git 保有一份您自己的代码副本和远程仓库 。
命令git fetch
通过从远程仓库获取数据来更新您的本地副本。 我们需要这个数据的原因是, 其他人可能对代码做了一些修改, 您想要不断更新自己 。
命令git pull
将远程仓库的更改引入到您保存自己的代码的位置。通常,git pull
这样做的方式是先做一个“ 直接获取” , 将远程仓库的本地副本更新, 然后将修改合并到您自己的代码存储处, 并有可能将您的工作副本合并到您自己的代码存储处 。
简简单简的答案是:git pull
简单git fetch
和继 继 继 继 继 继git merge
.
必须指出,git pull
会不管你喜不喜欢自动合并。这当然可能导致合并冲突。让我们假设你的远程是origin
并且你的分支是master
。如果您git diff origin/master
在拉车之前,你应该对潜在的合并冲突有某种了解,并且可以据此为你的当地部门做好准备。
除了拉和推,一些工作流程涉及git rebase
,例如这一条,我从相关条款中转述如下:
git pull origin master
git checkout foo-branch
git rebase master
git push origin foo-branch
如果你发现自己处于这种情况, 你可能会被诱惑git pull --rebase
除非您真的知道自己在做什么 否则我建议不要这么做man
页面git-pull
版本, 版本2.3.5
:
这是一个潜在危险的操作模式。 它重写历史, 当您已经发布历史时, 历史并不是好兆头。 除非您仔细阅读了 git- rebase(1) , 否则不要使用此选项 。
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式
- git pull -rebase和git pull -ff-only之间的区别