【问题标题】:How can I pull from one remote and push to another with git?如何使用 git 从一个遥控器拉出并推送到另一个遥控器?
【发布时间】:2014-08-11 19:38:58
【问题描述】:

我的 github 存储库有一个贡献者,他有一个 fork 并且正在一个分支上工作。我想将他们的分支拉到我自己的分支并进行修改,但仍要跟踪他们的。

我可以配置 git 以便当我在分支 foo 上时,

  • git pull 拉取自 contributor/foo
  • git push 推送到 origin/foo

这与问题How can I push to one url and pull from another using one remote? 相似但不同,因为该问题希望使用相同的远程名称。

【问题讨论】:

  • 看看这个。我认为我的问题的答案正是您所需要的:stackoverflow.com/questions/7420662/…
  • 你总是可以直接去git push origin foo ...实际上我总是使用这种形式,因为从推错地方恢复过来比输入这些东西更痛苦

标签: git git-branch


【解决方案1】:

您可以将上游分支设置为contributor/foo

git checkout foo
git branch -u foo contributor/foo

假设你首先有一个远程contributor

git remote add contributor https://github.com/user/fork_repo

您可以确保git push is always done on origin

git config remote.pushdefault origin

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-20
    • 2014-12-09
    • 2017-08-18
    • 2014-10-28
    • 1970-01-01
    • 2012-08-01
    • 2011-02-17
    相关资源
    最近更新 更多