日: 2019年2月2日

  • error: failed to push some refs to を対処する

    error: failed to push some refs to を対処する

    はじめに

    gitにpushできなくなったというトラブルの対処

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

    というエラーが発生。

    原因

    リモートリポジトリと、ローカルリポジトリに差分があることにより発生する。

    対処

    git push origin :branch
    git push origin branch

    remoteブランチを削除することになる。

    参考情報

    https://qiita.com/yoshixj/items/6441ab2cd6bc367e607d