2017-09-26 1 views
0

私はGitHub(Enterprise)でPRを行い、コミットはほとんどありません。私のレビューアが1に小さ​​なミスを犯す識別:プルリクエストを修正するにはどうすればよいですか?

* a401341c Did this (HEAD -> foo) 
* 08e97f86 Did that 
* 616cd4ad Done that 
* f3c6151b Accomplished this 
* 1af6e74f Fix this <-- Error there 
* a099fc19 Finished this 
* ab726eb3 Cherry-picked this (master, origin/master) 

私は補正を持つすべてのコミットを再適用、その後、競合せずにそれを戻すことはできませんので、最初のソリューションは1af6e74f後にすべてのコミットを元に戻すことです。

* 0c99cf29 Reapply Did this (HEAD -> foo) 
* 8806f36b Reapply Did that 
* 572e1122 Reapply Done that 
* 64ea3dc8 Reapply Accomplished this 
* 81e20976 Fix this (this time correctly) 
* d78a4534 Revert Fix this <-- Error there 
* c0d817a9 Revert Accomplished this 
* ed2bb3b2 Revert Done that 
* ea34322a Revert Did that 
* f81b78a3 Revert Did this 
* a401341c Did this 
* 08e97f86 Did that 
* 616cd4ad Done that 
* f3c6151b Accomplished this 
* 1af6e74f Fix this <-- Error there 
* a099fc19 Finished this 
* ab726eb3 Cherry-picked this (master, origin/master) 

次にgit push私のPRを更新してください。

第二の溶液はgit push -f

git checkout 1af6e74f 
git commit --amend -am "Fix this (with corrections)" 
git rebase --onto a401341c f3c6151b HEAD # Not sure this will work as written 
git branch -f foo HEAD 
git push -f 

を伴うだろうが、常に悪いもの良い解決策と後者の旧ソリューションですか?

+1

私はどちらか使用しないだろう、私はブーイングブーイングを固定します新しいコミットでもちろん、ブランチをリベースした場合、履歴はよりクリーンになります。しかし、あなたの支店が誰にも分かれていない場合にのみリベースすることが望ましいでしょう。したがって、あなたの質問に対する答えは、ブランチが共有されていない場合、後者の解決法が良い解決法であるということです。 –

+0

まあ、私はできません...私はちょうど私がパッチを適用することはできません私は 'git am mypatch'を使用したので、厳しい私の質問で明確にされていませんでした。特定のコミットを元に戻して変更する必要があります。 1回のコミットで 's/a \ w/b/g'と同じように、あとで' s/b/a/g'を実行することはできません。 – nowox

+0

リベースすることができない場合は、なぜそれについて質問したのですか、あるいはこの疑問はただの仮説ですか? –

答えて

1

質問

古いブランチと新しいブランチ(gitの差分a401341cの0c99cf29)との差分は何ですか?
妥当なパッチのように見えますが、バグの修正方法がはっきりと分かりますか?それは、単に新しいコンテンツを取ると、古い枝の上に新しいコミットとしてこれをコミットしない場合


git checkout foo 

# just to be on the safe side : work on a new temporary branch 
git checkout -b wip 

# go back to the old sate : 
git reset --hard a401341c # <- original "Did this" commit 

# get the content from new branch : 
git checkout 0c99cf29 . # <- don't forget the "." 

# check that it matches what you expect : 
git diff [--cached] ... 
git difftool -d [--cached] ... 

# if OK : commit ! 
git commit 


# make your local "foo" branch point to this commit : 
git checkout foo 
git reset --hard wip 
git branch -d wip 

# push : 
git push origin foo 
+0

この場合、通常は許可されない 'git push -f origin foo'を実行する必要があります。右 ? – nowox

+0

'git push -f'ではなくregumar pushになります。変更はリモートブランチの上でコミットされます。 – LeGEC

関連する問題