그래도 고쳐야 한다면 다른 작업자의 현재 작업 내용을 수동으로 백업해놓고, 이 수정 작업 수행 후, 현재 저장소를 삭제(또는 백업)하고 저장소를 새로 내려받고 나서 이전 백업 내용을 복원해야 합니다.
차라리 되돌려야 하는 부분이 있다면 revert 명령을 활용하세요.
수정한 본인 제외하고 모두가 꼬입니다...
아직 공유되지 않은 커밋이라도 수정 작업 중에 반영된 내용으로 이 후 커밋들과 충돌이 발생해서 회복하기 힘들게 꼬일 수 있습니다.
현재 수정하는 부분이 이 후 커밋에서 다르게 수정된 경우
파일 추가 삭제 등으로 추적(tracking)이 꼬이는 경우
소중한(복구가 안되면 화가 나고, 눈물이 날 정도인) 저장소이고, 본인이 수정하려는 내용이 확실히 꼬이지 않는다고 확신하는 경험자(경험자도 꼬이는 때 있습니다... 저도 백업하고 실행합니다...)가 아니라면 반드시 현재 저장소를 백업(.git 포함) 해두세요. 두번 세번 강조합니다. 반드시 하세요.
작업 위치 수집
커밋의 해시코드(hashcode) 앞 7자(전체도 상관없음)를 다음 2개를 찾아 기록해놓기
# Rebase dddd..9876 onto 9876 (4 commands) # # Commands: # p, pick <commit> = use commit # r, reword <commit> = use commit, but edit the commit message # e, edit <commit> = use commit, but stop for amending # s, squash <commit> = use commit, but meld into previous commit # f, fixup <commit> = like "squash", but discard this commit's log message # x, exec <command> = run command (the rest of the line) using shell
# Rebase dddd..9876 onto 9876 (4 commands) # # Commands: # p, pick <commit> = use commit # r, reword <commit> = use commit, but edit the commit message # e, edit <commit> = use commit, but stop for amending # s, squash <commit> = use commit, but meld into previous commit # f, fixup <commit> = like "squash", but discard this commit's log message # x, exec <command> = run command (the rest of the line) using shell
저장하고 나가면 끝
Successfully rebased and updated refs/heads/dev/test1.
2. 커밋 작성자 변경
1번 작업과 같이 대상을 골라 rebase 명령을 내리고 나온 편집기 화면의 원하는 커밋에서 pick 키워드를 edit 로 바꾸고 저장