如何同步一个分叉的存储库,因此它具有与原始存储库相同的状态?
我确实使用API创建了GitHub存储库的叉子。现在,有一段时间后,叉子和原始存储库不超出同步。
如何使用API或命令行GIT命令将叉子与原始存储库同步到相同的状态?
我试图删除叉子存储库,但我没有删除它的权利。
重新铺设原始存储库也似乎也不起作用,我会
7 commits behind owner:master.
在UI中像可见的那样传达信息。
还有其他想法吗?
我尝试了此页面但它不起作用。我有很多冲突。
只是要清楚:我不想合并任何东西。我想将原始存储库同步与分叉的存储库同步,因此分叉的存储库具有与原始存储库相同的状态(历史,投入等)。我不想合并任何东西,我想同步它。
就像在编程语言中一样,当您拥有Python dictionary mydict
时,它有一些数据,您只想用其他python dict替换其内容,您只会
mydict = other_dict
获得任何合并,通过将变量分配给某些内容来冲突。
我希望现在更清楚。
问题是我无法直接访问GitHub GUI,否则我只能删除叉子并再次从原始叉子叉。但这不起作用。我也没有使用API删除叉子的权利。
I did create a fork of a github repository using the API. Now after some while the fork and the original repository are out of sync.
How can I sync the fork to the same state as the original repository using the API or command line git commands?
I tried to remove the forked repository but I do not have the rights to remove it.
Re-forking the original repository also does not seem to work, I will have the message like
7 commits behind owner:master.
in the UI visible.
Any other idea?
I tried the solution #2 from this page but it did not work. I got many conflicts.
Just to be clear: I do not want to MERGE anything. I want to SYNC synchronize) the original repository with the forked repo, so the forked repo has the same state (history, commits, etc.) as the original repository. I do not want to merge anything, I want to SYNCHRONIZE it.
It is like in a programming language, when you have a python dictionary mydict
which has some data and you want to just replace its content with a different python dict, you just do
mydict = other_dict
you also never get any "merge conflicts" by assigning the variable to some content.
I hope this is clearer now.
The problem is that I do not have direct access to the github GUI, otherwise I could just delete the fork and fork it again from the origin. But this does not work. I also do not have the rights to delete the fork using the API.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道
gh
是否有任何要做的事情,但是从命令行Git,您可以通过git克隆的组合合理地接近 - mirror
和git推动 - mirror
。 将它们非常小心用作git push-mirror
可能非常具有破坏性:git克隆 - mirror ointer-repository-url
创建原始存储库的镜面克隆。此克隆仅用于步骤2,然后丢弃。git推动-Mirror fork-Repository-url
以擦除叉子的当前状态并按下全新状态。我实际上并未使用GitHub尝试过此操作,您可能会收到有关
refs/pull/
引用的警告,甚至在步骤2中引用您可能希望在没有
|的情况下运行此操作。 sh
首先,要确保它生成正确的git update -ref -d
命令。这简单地 deletes 所有refs/pull/
来自镜面克隆的名称,因此git push -mirror
不会尝试推动它们。I don't know if
gh
has anything to do it, but from command-line Git you can get reasonably close with a combination ofgit clone --mirror
andgit push --mirror
. Use these with great care asgit push --mirror
can be quite destructive:git clone --mirror original-repository-URL
to create a mirror clone of the original repository. This clone is only to be used for step 2, and then discarded.git push --mirror fork-repository-URL
to wipe out the current state of the fork and push all-new state.I have not actually tried this with GitHub, and you might get warnings or even errors about
refs/pull/
references in step 2. If this is a problem, add a "step 1.5":git for-each-ref --format="git update-ref -d %(refname)" refs/pull | sh
You may wish to run this without the
| sh
first, to make sure it generates the correctgit update-ref -d
commands. This simply deletes all therefs/pull/
names from the mirror clone, so thatgit push --mirror
does not try to push them.