LoginSignup
0
0

More than 1 year has passed since last update.

error: failed to push some refs to 'github.com:jojo232/raistech-aws202208.git'

Posted at

git pishしようと思ったら下記エラー発生

 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'github.com:jojo232/raistech-aws202208.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.

このcommitを行う前に、私がリモートでgithubのREADMEの変更を行っていたことが
今回のエラーの原因でした。

「リモートのファイルがローカルのファイルも最新版だから、そのファイルにpushできないですよ」ということみたいです。

対処法
いくつか対処法があるみたいです。

①git pull origin develop
git pull origin developでリモートの環境をローカルファイルにpullした後、
再度pushを行う。

②git fetchした後、git mergeする
①とやっていることはほとんど変わらず、pull=fetch + mergeという意味合いなのかと思います。

③git push ––forceで矯正的にpushする
こちらは、個人開発なら自分一人しかリポジトリを操作しないので大きな影響はなさそうですが、
チーム開発の場合だと自分以外にcommitやpushする人がいる無闇に使用すべきでは無い、という記事をいくつか確認しました。

まあ、再度作り直して、github上でファイルをいじらなければないも問題はなかったです。

0
0
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
0
0