repo sync之后不能自动 rebase 的定位

背景
最近在使用repo sync同步代码时老是报告:branch xxx is published (but not merged) and is now 1 commits behind。我之前是由推送过一笔提交,但是最后由于某种原因,我在Gerrit上Abandoned掉了这笔提交。

当时就觉得这和本地仓库可能有某种关联,只不过没有去细究,而是手动进行了rebase。
最后在.repo/repo/project.py中找到了相关信息:

    upstream_gain = self._revlist(not_rev(HEAD), revid)
    pub = self.WasPublished(branch.name, all_refs)
    if pub:
      not_merged = self._revlist(not_rev(revid), pub)
      if not_merged:
        if upstream_gain:
          # The user has published this branch and some of those
          # commits are not yet merged upstream.  We do not want
          # to rewrite the published commits so we punt.
          #
          syncbuf.fail(self,
                       "branch %s is published (but not merged) and is now %d commits behind"
                       % (branch.name, len(upstream_gain)))
		  return

当即恍然大悟,果然在对应的的.git/refs发现了一个published的链接文件,这个文件链接到repo项目下对应的仓库,查看其内容:里面记录了我在Gerrit上Abandoned掉的这笔提交。删除这个文件,在进行repo sync,顺利进行!

你可能感兴趣的:(git,git)