空飛ぶITコンサルタント

中小企業診断士が「AI」「パン」「補助金」について語ります

rails4でGithubにpushする時に大苦戦

1.getgubの使い方を見て真似ていた所、error発生。

githubは前々からLibraryの質問等で使っていたものの、railsアプリをpushすることが無かった。今回初めてpushしようとしたら大苦戦したの巻。

memo.yomukaku.net

このサイトが、情報は古いものの、簡潔明快であったために参考にする。

最後、以下のコマンドをポチっと...あれ

$ git push origin master
error: failed to push some refs to 'https://github.com/XXXX/YYYY.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.

--help見てなんとかしてくれ的な、非常に納得のいかないerror

2.これは兄貴御立腹です。


GARLICBOYS "兄貴御立腹" - YouTube

3.対策は作業用ブランチを一度かますこと(初回だけ)

git branch temp1
git checkout temp1
temp1というブランチを作成する。
git pull origin +master:temp1
この時点でoriginからファイルがすっぽり消えるけど、落ち着いて作業
git diff temp1 master
temp1とmasterを比較する。全くもって不毛な作業。
git checkout master
git marge temp1
temp1からmasterにmergeする作業。意味なし。

この後pushすると行けるようになる。何故なんだろう。
$ git push origin master

4.なぜブランチを初回だけかます必要があるのが、git不勉強につき不明です。

御指南ご鞭撻を宜しくお願いします。

 

他に参考にしたサイト

monsat.hatenablog.com