2017-09-26 7 views
0

커밋이 거의없는 GitHub (Enterprise)에서 홍보를했습니다. 내 검토가 하나의 작은 실수를 발견 커밋 :풀 요청을 수정하기위한 해결책은 무엇입니까?

* 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) 
: 그냥 다음, 충돌없이 되돌아 보정 모든 커밋을 다시 적용 할 수 없기 때문에

* 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 후 모든 커밋을 되돌리려하는 것입니다

다음 내 PR을 업데이트하려면 git push.

두 번째 솔루션은 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'를 사용했기 때문이다. 특정 커밋을 되돌리고 변경해야합니다. 마치 한 번에's/a \ w/b/g'하는 것처럼, 나중에's/b/a/g'를 할 수는 없습니다. – nowox

+0

rebase 할 수 없다면 왜 물어 보았습니까? 아니면 단지이 질문이 가상입니까? –

답변

1

질문 :

기존 지점과 새로운 지점 (자식은 diff a401341c의 0c99cf29) 사이의 DIFF는 무엇입니까?
버그가 수정 된 방법을 명확하게 나타내는 합리적인 패치처럼 보입니까? 만약 그렇다면


, 당신의 이전 분기의 상단에 커밋 새로운 내용을 새로운으로이 커밋 :

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