[英]Rebase local branch after pull from remote
I have a situation as the following where I have 2 local branches - one follows the other which follows the remote branch: A(origin/master)---B---C(topic)---D---E---F(master)
我有以下情况,我有 2 个本地分支 - 一个跟随另一个跟随远程分支:
A(origin/master)---B---C(topic)---D---E---F(master)
The topic branch follows origin/master branch.主题分支遵循origin/master分支。 Master branch follows topic branch.
主分支遵循主题分支。
After some time the origin/master grows and we get the following:一段时间后, origin/master增长,我们得到以下信息:
A---G(origin/master)
\
\
B---C(topic)---D---E---F(master)
So today, in order to rebase I'm doing the following:所以今天,为了变基,我正在做以下事情:
(topic): git pull --rebase
(topic): git checkout master
(master): git pull --rebase
(master): git checkout topic
(topic):
I have this issue with several local branches (several topics ) and I wonder if there is some command that does all this rebasing for me without the need to checkout between branches.我有几个本地分支(几个主题)的这个问题,我想知道是否有一些命令可以为我完成所有这些变基,而无需在分支之间结帐。 Does Such functionality exists?
是否存在此类功能?
Use:利用:
git fetch
first, to update all your origin/*
names after getting all new commits.首先,在获得所有新提交后更新您的所有
origin/*
名称。 Then use:然后使用:
git rebase origin/master
to rebase your own personal, un-pushed topic
branch to the updated origin/master
.将您自己的个人、未推送的
topic
分支重新设置为更新后的origin/master
。
(If you're annoyed that your own master
gets behind, consider simply deleting your master
branch. You can use the name origin/master
to find their latest master
any time you need to, and now that you do not have a master
of your own, you won't feel the urge to update it.) (如果您对自己的
master
落后感到恼火,请考虑简单地删除您的master
分支。您可以随时使用名称origin/master
来查找他们最新的master
,而现在您没有自己的master
拥有,你不会有更新它的冲动。)
If you have created a topic
over on origin
already, so that origin/topic
exists, that this won't update your own origin/topic
—well, unless someone else has done something on the Git over at origin
.如果您已经在
origin
上创建了一个topic
,因此origin/topic
存在,那么这不会更新您自己的origin/topic
——好吧,除非其他人在 Git 上在origin
上做了一些事情。 Then it will update your origin/topic
, and then you'd best figure out what that someone-else did.然后它会更新你的
origin/topic
,然后你最好弄清楚其他人做了什么。
After running git rebase origin/master
while on your own topic
, you can use git push --force
or git push --force-with-lease
to send the rebased commits and update topic
on the Git over at origin. After running
git rebase origin/master
while on your own topic
, you can use git push --force
or git push --force-with-lease
to send the rebased commits and update topic
on the Git over at origin. If someone else is using the topic
there, perhaps via some third Git's origin/topic
, you may mess with them, just as they might have messed with you above.如果其他人在那里使用该
topic
,也许是通过第三个 Git 的origin/topic
,您可能会惹恼他们,就像他们可能在上面惹恼您一样。
Hence, if you have pushed origin/topic
, make sure that everyone else agrees that it's OK for your to rebase your own topic
and to git push --force
(preferably -with-lease
).因此,如果您推送了
origin/topic
,请确保其他所有人都同意您可以重新设置自己的topic
和git push --force
(最好-with-lease
)。
(One common workflow is to use a third-party server like GitHub to store copies in case private Git repositories are on computers that crash or otherwise lose data. In this case, you may wish to push in-progress work: if everyone gets their own branch names here, and nobody uses anyone else's branches, this "get permission to update a shared branch" problem goes away, because these branches aren't shared, even though everyone can see everyone else's.) (一个常见的工作流程是使用像 GitHub 这样的第三方服务器来存储副本,以防私有 Git 存储库位于崩溃或以其他方式丢失数据的计算机上。在这种情况下,您可能希望推送正在进行的工作:如果每个人都得到他们的这里有自己的分支名称,没有人使用其他人的分支,这个“获得更新共享分支的权限”问题就消失了,因为这些分支不是共享的,即使每个人都可以看到其他人的分支。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.