git push したらエラーになってプッシュできなかった

ショコラ
ショコラ

git push したらエラーになってプッシュできなかった

エラーになったブランチをプルしてから、元のブランチをプッシュでキメマス。

もっさん先輩
もっさん先輩

手順

エラーになったブランチをプルしてから、元のブランチをプッシュする手順。

  1. エラーになったブランチ(! [rejected])をチェックアウトします。
git checkout {ブランチ}
  1. プルします。
git pull
  1. 元のブランチに戻ります。
git checkout {元のブランチ}
  1. プッシュします。
git push

以上

シチュエーション

git push を実行したところ、「error: failed to push some refs to」のエラーになっていまいプッシュできなかった。

To https://●●●@bitbucket.org/●●●/●●●.git
 ! [rejected]        {ブランチ} -> {ブランチ} (non-fast-forward)
error: failed to push some refs to 'https://●●●@bitbucket.org/●●●/●●●.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and merge the remote changes
hint: (e.g. 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Scroll to Top