LoginSignup
44
35

More than 3 years have passed since last update.

git pushがrejectされた時の対処法

Posted at

はじめに

git pushしたら下記のエラーが出てrejectされました。

To https://github.com/username/〇〇〇.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/username/〇〇〇.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.

解決方法

上記のエラーは自分がリモートの変更をpullしてから、pushするまでの間に、他からのpushがあるなどして、リモートリポジトリが変更されているためです。

$ git pull origin master

上記のコマンドでローカルリポジトリのmasterブランチをリモートリポジトリのmasterをmargeさせてあげた後に、再度pushし直します。

$ git push

参考サイト

44
35
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44
35