haiju's 開発メモ

開発に必要な情報を自分用にメモ

git pushがリジェクトされてリセットしてマージし直してる間にリモートが更新されてコンフリクトかよw

gitでローカルで更新したファイルをマージしてただけなのに、

コミットまでは問題なかったのに、突然リジェクトされて

思い当たる節がない・・・( ̄へ ̄|||) ウーム

不慣れな人ほどSourcetreeとかいう訳のわからないGUIツール

を使うのやめような。

権限がある人が分からないのでポチポチ押してる間に事故の元だから。

[とりあえずやったこと]

1. rejectされたのでエラーの後に出力されたhintの内容を確認。

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.

2. fast-forwardsについては前回、.gitconfigファイルに以下を設定済み。

[merge]

    ff = false

3. ログを確認すると、git commitまでは完了してたが気持ち悪いので

 取り消しコマンドを実行。

$ git reset HEAD

4.  取り消した後の状態を確認。

On branch xxxxx
Your branch and 'origin/xxxxx' have diverged,
and have 1 and 6 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)

nothing to commit, working tree clean

※ちなみにログは取り消し前にコミットした分が残存。

5. 他に更新したファイルがあるので再び、add + commit + push

 したらまた、リジェクトされた・・・( ̄へ ̄|||) ウーム

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

6.   pushの前にpullしろと言われてるようなので、素直にgit pull

 したら下記エラー。

Auto-merging xxxxxxxxxx
CONFLICT (content): Merge conflict in xxxxxxxxxxxx
Automatic merge failed; fix conflicts and then commit the result.

7. 自動マージって何?という疑問は残るが、コンフリクトしてる

 ファイルがあるらしいので内容を確認。

8. git resetした内容が不完全に残って比較したらコンフリクトしたよ

 って言われてるらしい(ほんまか?)( ̄へ ̄|||) ウーム

9. もう一度、状態を確認するとコミットの実行を取り消した時の

 変更がマージされてないよってメッセージが。

 (というか中途半端にgit resetコマンドで取り消された内容は

 どこに行ってたんだよ?)

Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: xxxxxxxxxx

10. 9のファイルをコミットしてリモートにpush。

 エラーは発生しなかったので、とりあえずはOKだと思うけど

 コレジャナイ感も相変わらずだな・・・

[参考サイト]

stackoverflow.com

qiita.com

stackoverflow.com

yu8mada.com

qiita.com

qiita.com

www-creators.com

quartet-communications.com

te2u.hatenablog.jp

note.com

lab.ewigleere.net

serebrov.github.io