LoginSignup
0
0

More than 5 years have passed since last update.

コンフリクトを直す手順

Last updated at Posted at 2018-11-18

「あなたの現在のブランチの先端が遅れているため、更新が拒否されました。
と表示された場合

gitエラーを解決するには:
"現在のブランチの先端が背後にあるため、更新が拒否されました"
https://code.i-harness.com/ja/q/157d34f
https://code-examples.net/ja/q/157d34f

原因

コンフリクト?

まず、最新のdevelopを取り込む

git pull --rebase origin develop

例
git pull --rebase origin future/event/308

それでもダメなら

git diff HEAD..origin/master

で差分を探して、
その差分があるファイルを自分のローカルで探して、差分があるリモートのファイルと同じようにする

そして、git add を実行して、git commit を実行すれば、競合を解決したマージコミットの完成です。
そのあとまたpushしてみる

コンフリクトの解消方法
http://www-creators.com/archives/1938

http://www.nowhere.co.jp/blog/archives/20170905-220040.html

流れ
『 gitエラーを解決するには: "現在のブランチの先端が背後にあるため、更新が拒否されました 』

1.すべてのステージングされていない変更をステージングします。

git add .

2.リモートと同期する。

git pull -r

rebase --continue
https://qiita.com/shuntaro_tamura/items/c505b76c1021a35ca9ff

git pushが出来ない事象を解決する手順

「あなたのブランチは、2つのコミットによって 'origin / feature / hoge / 001'より先です。」

    On branch feature/hoge/001
    Your branch is ahead of 'origin/feature/hoge/001' by 2 commits.
    (use "git push" to publish your local commits)

    nothing to commit, working tree clean

と表示されて、更に

「注意:taro-hogeは管理者ではありません。 別の人のコミットを押すことはできません。」

    ### NOTICE: taro-hoge is not administor. you can't push another person's commit.
    ### NOTICE: commit-authors-string:jiro-hoge,saburo-hoge
    ### CHECK_COMMAND: git log ffc00000egg0000gg00gg0g00g00g0g00g0g00g0..12rt34567jkfhvnfh891lkfijjjjjjuhyfkkkl30
    error: failed to push some refs to 'git@github.hoge.jp:hoge/sp-hoge.git'

と表示され、git pushが出来ない事象を解決する手順
※上記のgit log はデタラメに記載したものです。

原因

自分以外の第3者が先にコミットして、コンフリクトを起こした事が原因

やった事

$ git reset HEAD^

コミットをコミット前の状態に戻す。
(^ で一つ前 ^^なら二つ前のコミットが対象。)

    Unstaged changes after reset:
    M   pm/test/hoge/001/Page/tokyo/test3.php

    modified:   ../pm/test/hoge/001/Page/tokyo/test3.php

すると add する前の状態に戻ります。

$ git reset HEAD [ファイルパス]

ファイル名がわかる場合は↑

ただ、第3者がコミットしたファイルパスがどこにあるか分からない場合がほとんどなので、
自分より先にあるコミットを消すという手順でやる事。

git checkout (ファイルパス)

で変更自体を無しにします。

例
../pm/test/hoge/001/Page/tokyo/test3.php
の場合
git checkout ../pm/test/hoge/001/Page/tokyo/test3.php

特定のファイルではなく、全て元に戻したい場合

git checkout .
git status

で確認したら、commitが綺麗になくなってるので、
再度pushしてみる

git push origin feature/hoge/001

    Everything up-to-date

↑と表示され、pushするファイル自体が無くなる。

ので改めて、改修するファイルを更新し、再度

add → commit → push

して、終了。

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