「あなたのブランチは、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者が先にコミットして、コンフリクトを起こした事が原因
やった事
その1
$ 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者がコミットしたもファイルは基本分からない場合がほとんどなので、
自分より先にあるコミットを消すという手順でやる事。
その2
git checkout (対象ファイル先)
で変更自体を無しにします。
例
../pm/test/hoge/001/Page/tokyo/test3.php
の場合
git checkout ../pm/test/hoge/001/Page/tokyo/test3.php
特定のファイルではなく、全て元に戻したい場合
git checkout .
その3
git status
で確認したら、commitが綺麗になくなってるので、
再度pushしてみる
git push origin feature/hoge/001
Everything up-to-date
↑と表示され、pushするファイル自体が無くなる。
ので改めて、改修するファイルを更新し、再度
add → commit → push
して、終了。