web関連

【git】git pushでmasterブランチにpushしたらエラーが出た時の備忘録

developブランチで作業をして、ローカルでmasterブランチにマージして「add→commit」してpushしようとしたらエラーが出た時の備忘録

git pull origin masterを実行したら直った

以下のエラーが出た

$ git push origin master
To https://bitbucket.org/○○/××.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://bitbucket.org/○○/××.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

以下のコマンドを打ったら直った

git pull origin master

多分、ローカルのmasterブランチでコミットまでしてリモートリポジトリにpushしていなくてそれがエラーの原因だったんだと思う
だかpullコマンドでfetchを更新してmergeをしたことでリモートリポジトリと同じ内容になった事で解消されたのかなと

その後にローカルのdevelopブランチを再度マージしてリモートリポジトリにpushしたら正常にpushできた

Leave a Comment

入力エリアすべてが必須項目です。メールアドレスが公開されることはありません。

内容をご確認の上、送信してください。