【问题标题】:Locally add the remote to the GitHub original (forked from) repository在本地将远程添加到 GitHub 原始(派生自)存储库
【发布时间】:2015-02-27 03:25:06
【问题描述】:

假设我有一个现有存储库 (https://github.com/someguy/foo) 的 GitHub 分支 (https://github.com/sitaktif/foo)。

我有一个本地 git 存储库,它只有一个 git remote (origin),指向我的 GitHub 分支:

# Output from `git remote -v`
origin  git@github.com:sitaktif/foo (fetch)
origin  git@github.com:sitaktif/foo (push)

我想将 parent 存储库添加到我的遥控器(即我最初在 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)

我知道我可以手动添加远程,但我想要的是自动执行此操作(这样我就不必手动查找每个本地存储库的父/原始存储库的地址)。

【问题讨论】:

    标签: git github git-remote


    【解决方案1】:

    目前我发现的唯一解决方案是在脚本中使用 GitHub API。

    我创建了一个并在那里提供:https://github.com/sitaktif/github-utils/blob/master/github_add_upstream.py

    我包含了最少的文档,以防有人感兴趣。随意建议对脚本的改进。代码远非完美,因此欢迎提出拉取请求。

    【讨论】:

      猜你喜欢
      • 2021-10-03
      • 2015-12-16
      • 2016-05-10
      • 2010-10-26
      • 2013-12-03
      • 2013-08-02
      • 2011-08-13
      • 1970-01-01
      • 2011-09-03
      相关资源
      最近更新 更多