2017-04-12 2 views
0

내가 FILE1이 commit2에서 편집되지 않았을 것을 깨달았다이전 git 커밋의 파일을 편집하는 방법은 무엇입니까?

HEAD 
commit999: Edit file999 
commit998: Edit file998 
... 
commit3: Edit file3 
commit2: Edit file2 and file1 
commit1: Edit file1 

저지른와 나는 자식의 repo를 jave 말할 수 있습니다. commit2에서 file1의 변경 사항을 되돌리고 싶지만,이 되돌리기를 위해 새로운 커밋을하고 싶지는 않습니다.

내가 원하는 것을 할 수 있습니까? 그렇다면 어떻게해야합니까?

(만 나는이 자식의 repo. 그래서, 예를 들어, push -f origin master 어떤 더러운 일을 걱정하지 않는다 사용)

+2

['git rebase --interactive'] (https://git-scm.com/docs/git-rebase#git-rebase--i)에 대해 읽어보십시오. – axiac

답변

0

이 "개정이 개정"하여 수행 할 수 있습니다 후 체리 따기 모든 위에 일을 그것은 .... 이런 식으로 뭔가 : 작동해야

git checkout commit2 git checkout HEAD~1 -- <path-to-file1> # checkout file1 as it was on the previous revision git commit --amend --no-edit # create a _new_ revision git cherry-pick commit2..commit999 # use old rev IDs for commit2 and commit999 git checkout -b new-branch # create and checkout new branch if you feel like it

.

관련 문제