代码之家  ›  专栏  ›  技术社区  ›  Richard

试图推到GitHub

  •  -2
  • Richard  · 技术社区  · 6 年前

    push 到远程分支 my_branch .

    我得到以下信息:

    $ git push -u origin my_branch
    To github.com:xxxx/richard-m-xxxx.git
     ! [rejected]        my_branch -> my_branch (non-fast-forward)
    error: failed to push some refs to 'git@github.com:xxxx/richard-m-xxxx.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

    上面说我当地的分部( )在遥远的分支后面。我试过了 git pull

    $ git pull
    There is no tracking information for the current branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details.
    
        git pull <remote> <branch>
    
    If you wish to set tracking information for this branch you can do so with:
    
        git branch --set-upstream-to=origin/<branch> my_branch
    

    有人能告诉我去的步骤吗 我的项目到远程分支 我的分公司

    非常感谢。

    更新

    $ git pull origin my_branch
    From github.com:xxxx/richard-m-xxxx
     * branch            my_branch  -> FETCH_HEAD
    fatal: refusing to merge unrelated histories
    

    再说一遍:

    $ git push origin my_branch
    To github.com:xxxx/richard-m-xxxx.git
     ! [rejected]        my_branch -> my_branch (non-fast-forward)
    error: failed to push some refs to 'git@github.com:xxxx/richard-m-xxxx.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    
    1 回复  |  直到 6 年前
        1
  •  -3
  •   Richard    6 年前

    我在这里找到了解决办法: https://github.community/t5/How-to-use-Git-and-GitHub/How-to-deal-with-quot-refusing-to-merge-unrelated-histories-quot/td-p/12619

    git pull --allow-unrelated-histories origin my_branch