Ars*_*sum 2 git github git-pull
假设我在分支“abc-test”
git pull origin master
Run Code Online (Sandbox Code Playgroud)
这是否会将 master 分支与我当前的分支('abc-test')合并,或者我是否需要运行更多命令?
运行git fetch以获取最新更改,然后运行git rebase master以将分支更新为 master 中的最新更改。
现在,回答你的问题:是的,git pull origin master确实合并它们。
但是,您可能想要的是将 master 的提交应用到您的分支,然后在它们之上重新应用您的提交。
这就是所谓的变基。git-rebase 手册(您可以直接从终端访问,其中git rebase --help充满了有用的图表,可帮助您了解提交图的样子。
这是其中之一:
Assume the following history exists and the current branch is "topic":
A---B---C topic
/
D---E---F---G master
From this point, the result of the following command:
git rebase master
would be:
A'--B'--C' topic
/
D---E---F---G master
Run Code Online (Sandbox Code Playgroud)
如果你使用git pull,你的图表很快就会变得非常混乱。特别是如果您开始使用它使用来自远程存储库的新提交来更新本地分支,因为那样您将创建从分支到自身的合并提交,这是不必要的并且通常会产生误导。
大多数这些情况可以通过运行git pull --rebase或简单地git pull -r代替 git pull 来避免。
提示:git log --oneline --graph尽可能频繁地使用,这样您就可以习惯存储库的图表以及每个 git 命令对其的影响。
注意:变基太深时要小心。阅读 git-rebase 手册。
| 归档时间: |
|
| 查看次数: |
11667 次 |
| 最近记录: |