代码之家  ›  专栏  ›  技术社区  ›  Raven Cheuk

将不同的孤立分支热交换到gh页面

  •  -1
  • Raven Cheuk  · 技术社区  · 5 年前

    我推到另一个heroku遥控器时遇到问题。

    为了检查自己,我将整个项目目录重命名为_backup,然后:

    git clone account/repo_name
    
    git remote add repo2 git@heroku.com:repo2.git
    
    git push repo2 branch_abc:master
    

    但我仍在努力

    hint: Updates were rejected because a pushed branch tip is behind its remote
    hint: counterpart. Check out this branch and merge the remote changes
    hint: (e.g. 'git pull') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

    我试过几个这样的问题和答案,但对我来说不起作用,尽管如此,还是会出现错误。

    0 回复  |  直到 7 年前
        1
  •  42
  •   Michael Durrant    12 年前

    如果你不关心repo2中当前的内容,并且确信完全覆盖它是可以的 然后你可以使用:

    $ git push -f git@heroku.com:<heroku repo name>.git
    

    记住 push -f 可以消除其他开发人员的更改 如果它们是你上次从回购中取出后发布的。。。所以在多开发者团队中使用时一定要格外小心!
    在这种情况下,heroku总是在下游,github是管理和维护代码的地方,因此 推-f 在heroku上,这是一个更安全的选择。

        2
  •  7
  •   Michael James Kali Galarnyk    9 年前

    我一直非常喜欢使用git pull——rebase和git push origin master。自从很多地方不允许使用push-f(特别是使用bitbucket的地方)以来,我已经在几个地方工作过。

    git pull --rebase 
    git push origin master
    

    在远程(在线网站)上已经进行了更改之后,rebase将应用您的更改。这段视频详细介绍了您的具体问题,并使用git pull——rebase解决了它 https://youtu.be/IhkvMPE9Jxs?t=10m36s

        3
  •  6
  •   Michael Durrant    12 年前

    如果你先退出另一个回购协议:

    git pull repo2

    这将合并到其他回购协议的更改中,您可以添加并提交这些更改。

    然后你可以收回回购协议。