LoginSignup
0
0

More than 1 year has passed since last update.

【Rails】git push ができない

Posted at

はじめに

いつも通りgit pushしたらエラーが発生して実行できませんでした。
同じことが起きた人のメモになればと思い、対処法を書き残します。

起こったエラー

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

原因

push予定のコミットをする前に、リモートのgithubを編集していたこと。
私はwebサイトで作成したER図を直接リモートgithubに追加していました。

解決

方法①
git pull origin developでリモート環境をpullした後、再度pushする。

方法②
git fetchした後、mergeする。

方法③
git push --forceで強制的にpushする。

個人開発やチーム開発などによる状況によって使い分けるのがよさそうですね。

参考

【git】error: failed to push some refs to "URL"のエラー対処法

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