运行 `git pull --rebase`,它是根据什么变基的?
Running `git pull --rebase`, what does it rebase against?
我看到很多这样的例子:
git pull --rebase
但我想知道哪个分支合并到当前分支中。不应该是git pull --rebase <master>
还是git pull --rebase <dev>
?
在使用其他人的存储库时,需要记住一些基本的 Git 命令:
git clone
git fetch
git merge
git pull
这些命令在与远程存储库交互时非常有用。 clone
和 fetch
从存储库的远程 URL 下载远程代码到您的本地计算机。 merge
用于将不同人的工作与您的工作合并在一起,pull
是 fetch 和 merge 的组合。
我们将在下面深入介绍这些命令。
克隆
要获取另一个用户存储库的完整副本,请像这样使用 git 克隆:
git clone https://github.com/USERNAME/REPOSITORY.git
将存储库克隆到您的计算机
克隆存储库时,您可以从多个不同的 URL 中进行选择。登录 GitHub 后,这些 URL 可在存储库详细信息下方找到:
它将从远程拉取您正在工作的当前分支,并将其变基到您的本地分支。
git-pull - Fetch from and integrate with another repository or a local
branch
git-rebase - Forward-port local commits to the updated upstream head
现在,
git pull --rebase
= git fetch
+ git rebase
against tracking upstream
branch
用例:假设您和您的队友一起在同一分支上开发一项新功能。他做了一些更改并将它们推送到远程。现在您需要获取并变基您的分支以合并他的更改。
您也可以使用 git pull --rebase <currentBranch>
代替 git pull --rebase
。
如果您明确想要将另一个分支更改合并到您的本地分支,那么您可以使用 git pull --rebase <otherBranch>
.
它首先获取 origin/theBranch
,然后在 origin/theBranch
的基础上重新设置您的更改。
配草图:
在git pull --rebase
之前:
*--*--*--*--A <- origin/theBranch
\
M--Y <- theBranch # your local branch
git pull --rebase
第 1 步:git fetch
*--*--*--*--A--B--C--D <- origin/theBranch
\
M--Y <- theBranch
git pull --rebase
第 2 步:git rebase origin/theBranch
*--*--*--*--A--B--C--D <- origin/theBranch
\
M'--Y' <- theBranch
我看到很多这样的例子:
git pull --rebase
但我想知道哪个分支合并到当前分支中。不应该是git pull --rebase <master>
还是git pull --rebase <dev>
?
在使用其他人的存储库时,需要记住一些基本的 Git 命令:
git clone
git fetch
git merge
git pull
这些命令在与远程存储库交互时非常有用。 clone
和 fetch
从存储库的远程 URL 下载远程代码到您的本地计算机。 merge
用于将不同人的工作与您的工作合并在一起,pull
是 fetch 和 merge 的组合。
我们将在下面深入介绍这些命令。
克隆
要获取另一个用户存储库的完整副本,请像这样使用 git 克隆:
git clone https://github.com/USERNAME/REPOSITORY.git
将存储库克隆到您的计算机
克隆存储库时,您可以从多个不同的 URL 中进行选择。登录 GitHub 后,这些 URL 可在存储库详细信息下方找到:
它将从远程拉取您正在工作的当前分支,并将其变基到您的本地分支。
git-pull - Fetch from and integrate with another repository or a local branch
git-rebase - Forward-port local commits to the updated upstream head
现在,
git pull --rebase
=git fetch
+git rebase
against tracking upstream branch
用例:假设您和您的队友一起在同一分支上开发一项新功能。他做了一些更改并将它们推送到远程。现在您需要获取并变基您的分支以合并他的更改。
您也可以使用 git pull --rebase <currentBranch>
代替 git pull --rebase
。
如果您明确想要将另一个分支更改合并到您的本地分支,那么您可以使用 git pull --rebase <otherBranch>
.
它首先获取 origin/theBranch
,然后在 origin/theBranch
的基础上重新设置您的更改。
配草图:
在
git pull --rebase
之前:*--*--*--*--A <- origin/theBranch \ M--Y <- theBranch # your local branch
git pull --rebase
第 1 步:git fetch
*--*--*--*--A--B--C--D <- origin/theBranch \ M--Y <- theBranch
git pull --rebase
第 2 步:git rebase origin/theBranch
*--*--*--*--A--B--C--D <- origin/theBranch \ M'--Y' <- theBranch