git pull 和 git pull origin <branchName> 有什么区别
What is the difference between git pull and git pull origin <branchName>
我有一个父分支 origin/develop
,我从这个分支创建了一个子分支 feature/NewFeatureBranch
我现在 feature/NewFeatureBranch
使用 git checkout feature/NewFeatureBranch
现在我已经完成 git pull
并且可以看到几个新分支正在下载到我的本地机器上,它们的父节点都是 develop
在另一种情况下,我已经完成 git pull origin develop
,在这种情况下,正在下载从其他分支新检入的文件 develop
。
git pull
是否表现得像 git fetch
而 git pull origin develop
表现得像 git fetch + git merge
。
文档的第一句话:
In its default mode, git pull is shorthand for git fetch
followed by git merge FETCH_HEAD
.
所以 git pull
只是一个 shorthand。 Git 对您的意思做出一些假设并补充缺失的部分。因此,默认情况下 shorthand 的用途是:
git fetch
git merge <remote-tracking-branch-that-current-branch-tracks> [into the current branch]
同样,如果你真的给了一个遥控器和一个分支,你还是说:
git fetch remote
git merge remote/branch [into the current branch]
您可以更改 shorthand 的含义(作为 config
设置的一部分),例如 rebase
而不是 merge
,但大多数人不't。一般来说,有些人认为最好根本不说 git pull
,而是说 fetch
,然后,如果需要,再说 merge
或 rebase
或其他什么,明确地。这使您有机会“环顾四周”并决定如何进行。
我有一个父分支 origin/develop
,我从这个分支创建了一个子分支 feature/NewFeatureBranch
我现在 feature/NewFeatureBranch
使用 git checkout feature/NewFeatureBranch
现在我已经完成 git pull
并且可以看到几个新分支正在下载到我的本地机器上,它们的父节点都是 develop
在另一种情况下,我已经完成 git pull origin develop
,在这种情况下,正在下载从其他分支新检入的文件 develop
。
git pull
是否表现得像 git fetch
而 git pull origin develop
表现得像 git fetch + git merge
。
文档的第一句话:
In its default mode, git pull is shorthand for
git fetch
followed by git mergeFETCH_HEAD
.
所以 git pull
只是一个 shorthand。 Git 对您的意思做出一些假设并补充缺失的部分。因此,默认情况下 shorthand 的用途是:
git fetch
git merge <remote-tracking-branch-that-current-branch-tracks> [into the current branch]
同样,如果你真的给了一个遥控器和一个分支,你还是说:
git fetch remote
git merge remote/branch [into the current branch]
您可以更改 shorthand 的含义(作为 config
设置的一部分),例如 rebase
而不是 merge
,但大多数人不't。一般来说,有些人认为最好根本不说 git pull
,而是说 fetch
,然后,如果需要,再说 merge
或 rebase
或其他什么,明确地。这使您有机会“环顾四周”并决定如何进行。