rebase 대신 reset 을 입력해 commit 된 작업을 날려버릴 수 있다.
$ git reset master
Unstaged changes after reset:
D c.txt
'branch2 - 1' 이 날라갔다.
$ git reflog
04a157f (HEAD -> branch2, master) HEAD@{0}: reset: moving to master
a155f44 HEAD@{1}: commit: branch2 - 1
...
날라가기 전으로 되돌리기 위해 reflog 로 시점을 확인하자. HEAD@{1} 로 되돌리면 된다.
$ git reset --hard HEAD@{1}
HEAD is now at a155f44 branch2 - 1
reset 명령어를 사용해 HEAD@{1} 로 되돌리면 된다.
[GIT] reset 한거 취소하는 방법
원래는 remote 에 올리지 않은 여러 commit 이 있는 상태에서 한참 개발 중에 잠시 이전 commit 소스로 돌아가서 확인 좀 하려 했다.믈론 check out 으로 이동해도 되지만, 현재까지 작성한 코드랑 계속
88240.tistory.com
https://seosh817.tistory.com/297
[Git] git reflog를 이용하여 git reset --hard로 지워진 커밋 복구하기
Git reflog란? git reflog는 로컬 저장소에서 HEAD의 업데이트를 기록을 출력합니다. 업데이트의 내용은 저장소 디렉토리의 .git/logs/refs/heads/. 혹은 .git/logs/HEAD에 기록되며 git reflog는 이 내용을 출력합니
seosh817.tistory.com