![](/img/trans.png)
[英]Update remote forked repository without get it cloned locally from Github
[英]Locally add the remote to the GitHub original (forked from) repository
比方说,我有一个GitHub上叉( https://github.com/sitaktif/foo
现有资源库(的) https://github.com/someguy/foo
)。
我有一个本地git存储库,其中只有一个git remote ( origin
),指向我的GitHub fork:
# Output from `git remote -v`
origin git@github.com:sitaktif/foo (fetch)
origin git@github.com:sitaktif/foo (push)
我想将父存储库添加到我的遥控器(即我最初从GitHub上分叉的存储库),以便最终看起来像这样:
# Output from `git remote -v`
origin git@github.com:sitaktif/foo (fetch)
origin git@github.com:sitaktif/foo (push)
upstream https://github.com/someguy/foo (fetch)
upstream https://github.com/someguy/foo (push)
我知道我可以手动添加远程,但是我想要的是自动执行此操作(这样我就不必手动找到每个本地存储库的父/原始存储库的地址)。
到目前为止,我发现的唯一解决方案是在脚本中使用GitHub API。
我已经创建了一个,并在那里提供了它: https : //github.com/sitaktif/github-utils/blob/master/github_add_upstream.py
如果有人感兴趣,我只提供了很少的文档。 随时提出对脚本的改进建议。 该代码远非完美,因此欢迎请求pull。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.