鶏口牛後な日々

心の赴くまま、やりたいことを仕事に。

gitでpushしたのにrejectされた!

状況を書いておくと、あるブランチでpushして、マージリクエストを送ったのだが、
指摘があったので修正して、それをpushし直そうとした。
ただ、1回目pushした時から時が経っていたので、git pull --rebase してから修正し、pushしようとしたところ、以下のエラーが出てしまった。



! [rejected] <ブランチ名> -> <ブランチ名> (non-fast-forward)
error: failed to push some refs to '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.



さて、何かと言うと、一度pushしてマージリクエストを送って、修正してもう一度push&MRは送れるのだが、一度git pull --rebaseや、git commit --amendしてしまうと、別のものと認識されてしまって、git pushできなくなるらしい。
その場合でも、git push -f(強制的に)オプションをつければpushはできる。