failed to push some refs to **した時の対処法 [github]

はじめに

! [rejected] develop -> develop (non-fast-forward) error: failed to push some refs to ...

というエラーがでたので備忘録

結論

過去に一度remoteにpushした場所との整合性がとれずerrorがでてしまったらしいです。

// branch-nameブランチを削除
git push origin :branch-name

// ブランチをpush
git push origin branch-name

詳細

  1. ローカルのhogeブランチをリモートのhogeブランチにpush

    git push {ローカルのhoge}:{リモートのhoge}

  2. リモートブランチを削除

    git push origin {何もない!}:{リモートのhoge}

    git push origin :hoge=リモートのhogeブランチを削除

参考

git push 時の error: failed to push some refs to - Qiita

今さら聞けないgit pushコマンド - Shoichi Matsuda's diary