日: 2018年8月15日

  • hint: Updates were rejected because the tip of your current branch is behind

    hint: Updates were rejected because the tip of your current branch is behind

    はじめに

    git pushすると以下のようなエラーが出てrejectされることがある

    $ git push origin BranchName
    error: failed to push some refs to 'xxxx'
    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.
    $

    原因

    local branchが古い

    対処

    local branchを最新にする必要がある

    $ git pull origin BranchName
    From xxxx
     * branch            xxxx -> FETCH_HEAD
    Auto-merging xxxx
    Merge made by the 'recursive' strategy.
     xxxx | 1 +
     1 file changed, 1 insertion(+)
    $