pushで失敗
1 2 3 4 5 6 7 8 |
To github.com:ambiesoft/charsize.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@github.com:ambiesoft/charsize.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し忘れたり、pullしてpushする間に他の人がpushしたらなるのだと思われる。
pullで失敗
pushで失敗した場合、pullしてからpushすれば普通は大丈夫だったが、pullでコンフリクトが出てしまう。
1 2 3 4 |
error: Pulling is not possible because you have unmerged files. hint: Fix them up in the work tree, and then use 'git add/rm <file>' hint: as appropriate to mark resolution and make a commit. fatal: Exiting because of an unresolved conflict. |
このコンフリクトを直す。
status
まずはstatusを確認
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
(master|MERGING)$ git status On branch master Your branch and 'origin/master' have diverged, and have 1 and 1 different commits each, respectively. (use "git pull" to merge the remote branch into yours) You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge) Changes to be committed: modified: src/main.cpp Unmerged paths: (use "git add <file>..." to mark resolution) both added: src/.gitignore (master|MERGING)$ |
これを見るとsrc/.gitignoreがコンフリクトしているみたいなのでこれを編集する。実際このファイルを開くと以下のようになっている。
1 2 3 4 5 6 7 |
<<<<<<< HEAD .vs/ Debug/ Release/ ======= a.out >>>>>>> a14ef8e3cac779dc3dc3d5e8882beb566351f423 |
<<<<<<< HEADから=======と=======から>>>>>>> a14ef8e3cac779dc3dc3d5e8882beb566351f423までを手動マージして直せばいいはず。以下のように直した。
1 2 3 4 |
.vs/ Debug/ Release/ a.out |
これでgit addすれば直ったことになるはず。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
(master|MERGING)$ git add src/.gitignore (master|MERGING)$ git status On branch master Your branch and 'origin/master' have diverged, and have 1 and 1 different commits each, respectively. (use "git pull" to merge the remote branch into yours) All conflicts fixed but you are still merging. (use "git commit" to conclude merge) Changes to be committed: modified: src/.gitignore modified: src/main.cpp (master|MERGING)$ |
あとはコミットしてpushしてみると成功した。