繁体   English   中英

重新建立基础后,本地分支显示在远程分支的前面

[英]Local branch shown ahead of remote branch after rebasing

每次我重新建立本地分支的基础时, git status显示以下内容:

# On branch --blah--
# Your branch is ahead of 'origin/--blah--' by 11 commits.

只有在我推送到分支(实际上并没有推送任何内容)之后,它才说“ Everything up-to-date

这是奇怪的行为,我怀疑我缺少一些基本知识。 为什么会这样呢?

git rebase origin/branch作用是将您的工作放在本地副本中的origin/branch分支的顶部。

当你有:

local_branch: 1--2--3--4--1'--2'--3'
remote_branch: 1--2--3--4--a--b--c 

然后通过发出git rebase remote_branch你最终会

local_branch: 1--2--3--4--a--b--c--1'--2'--3'
remote_branch: 1--2--3--4--a--b--c 

这意味着当前您的local_branch实际上是您基于其进行远程操作的一些提交。

之后git push将导致

local_branch: 1--2--3--4--a--b--c--1'--2'--3'
remote_branch: 1--2--3--4--a--b--c--1'--2'--3'

这样您的当地人就可以保持最新状态

查看git-rebase文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM