2012-12-02 9 views
1

파트너와 함께 힘내 프로젝트를하고 있습니다. 나는 약간의 변경을 가한 다음 의도 한 것보다 많은 파일을 실수로 추가하고 커밋하여 마스터 리포지토리에 밀어 넣었습니다. 최종 커밋까지 원격 저장소를 어떻게 롤백합니까?하지만 올바르게 다시 추가하고 커밋 할 수 있도록 내 로컬 복사본을 보존합니까?힘내 - 이전 커밋으로 롤백

답변

2

당신은 특정 버전으로 리모컨을 밀어 git push 말할 수는 :

git push origin HEAD~1:master 

설명 :

  • origin 원격 REPO
  • HEAD~1의 이름은 소스 refspec –입니다 푸시 할 개정. HEAD~1은 현재 로컬 HEAD 뒤에 하나의 커밋을 의미합니다.
  • master은 푸시 할 원격 분기 –입니다. 여기에서 가져온
+0

감사합니다 다시 취소! 이것은 완벽하게 작동했습니다. – user1436111

1

답변 : How to undo last commit(s) in Git?

은 커밋과

$ git commit ...    (1) 
$ git reset --soft HEAD^  (2) 
$ edit      (3) 
$ git add ....    (4) 
$ git commit -c ORIG_HEAD  (5) 
This is what you want to undo 

This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before "reset". 

Make corrections to working tree files. 

Stage changes for commit. 

"reset" copies the old head to .git/ORIG_HEAD; redo the commit by starting with its log message. If you do not need to edit the message further, you can give -C option instead. 
관련 문제