Git repo 同步错误:分支 XYZ 已发布(但未合并),现在落后 1 次提交

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7004126/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:48:00  来源:igfitidea点击:

Git repo sync error: branch XYZ is published (but not merged) and is now 1 commits behind

gitrepository

提问by user886883

I had submitted two patchsets for a change, the first with "git commit -s", and the subsequent with git commit --amend -s". After the review of second patchset, was asked to make some more modifications for an improvement. The overall change/patch itself is pending approval, and has not yet been merged.

我提交了两个补丁集进行更改,第一个使用“git commit -s”,随后使用 git commit --amend -s”。在第二个补丁集后,被要求进行更多修改以进行改进。整体更改/补丁本身正在等待批准,尚未合并。

I made the modificatione needed, and did “git add” on 6 (6 files had changed since the last patchset) of the total 7 files that are part of the change, and did a "git commit -- amend -s". I did a "repo sync", no errors, but did not "repo upload" yet.

我进行了所需的修改,并在作为更改一部分的总共 7 个文件中的 6 个(自上次补丁集以来更改了 6 个文件)上执行了“git add”,并执行了“git commit -- amend -s”。我做了一个“回购同步”,没有错误,但还没有“回购上传”。

Then I remembered that one of the files had been set incorrectly with non-default values for two debug flags in the above commit. So I went back and changed that one file again, then did an “git add” of that one file, and a “git commit --amend -s”, which went through withour errors, just like the earlier “git add” and “git commit --amend -s” above.

然后我记得其中一个文件被错误地设置为上述提交中两个调试标志的非默认值。因此,我返回并再次更改了那个文件,然后对该文件进行了“git add”和“git commit --amend -s”,它没有出现错误,就像之前的“git add”和上面的“git commit --amend -s”。

When I did a repo sync again prior to doing the repo upload, I got the following error:

当我在进行 repo 上传之前再次进行 repo 同步时,出现以下错误:

"error: : branch topic1 is published (but not merged) and is now 1 commits behind"

“错误::分支 topic1 已发布(但未合并),现在落后 1 次提交”

What is the best/easiest way to fix this and do the repo upload?

解决此问题并执行 repo 上传的最佳/最简单方法是什么?

thanks in advance.

提前致谢。

回答by khester

I was just searching for this and happened upon the answer. do "git rebase ". This will reparent your changes to the updated branch. You might need to perform merges as prompted.

我只是在寻找这个并偶然发现了答案。做“git rebase”。这会将您的更改重新设置为更新的分支。您可能需要根据提示执行合并。

回答by bjc

Use "repo rebase"

使用“repo rebase”



Summary

概括

Rebase local branches on upstream branch

在上游分支上重新设置本地分支

Usage: repo rebase {[...] | -i ...}

用法:repo rebase {[...] | -一世 ...}

Options: -h, --help show this help message and exit -i, --interactive interactive rebase (single project only) -f, --force-rebase Pass --force-rebase to git rebase --no-ff Pass --no-ff to git rebase -q, --quiet Pass --quiet to git rebase --autosquash Pass --autosquash to git rebase --whitespace=WS Pass --whitespace to git rebase --auto-stash Stash local modifications before starting

选项:-h, --help 显示此帮助信息并退出 -i, --interactive 交互式 rebase(仅限单个项目) -f, --force-rebase Pass --force-rebase to git rebase --no-ff Pass --no-ff to git rebase -q, --quiet Pass --quiet to git rebase --autosquash Pass --autosquash to git rebase --whitespace=WS Pass --whitespace to git rebase --auto-stash Stash local开始前的修改

Description

描述

'repo rebase' uses git rebase to move local changes in the current topic branch to the HEAD of the upstream history, useful when you have made commits in a topic branch but need to incorporate new upstream changes "underneath" them.

'repo rebase' 使用 git rebase 将当前主题分支中的本地更改移动到上游历史记录的 HEAD,当您在主题分支中进行提交但需要在它们“下方”合并新的上游更改时非常有用。