ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 사라진 commit을 찾아 push 하기
    DevOps/Git 2023. 1. 4. 20:55

    1. commit의 hash값을 찾는다

    $ git reflog

     

    2. 현재 HEAD를 해당 commit의 hash값으로 옮긴다.

    $ git checkout 76ca7d01

     

    3. commit의 hash값 위에 있는 HEAD를 작업하던 branch에 붙인다.

    $ git branch master

    fatal: A branch named 'master' already exists.

    위와 같은 에러가 뜨면 강제로 실행!

    $ git branch master -f 

     

    4. 작업하던 branch로 checkout한다. 

    $ git checkout master

     

    5. commit 이력이 원하는대로 변경되었는지 확인한다. 

    $ git log

     

    6. 원격에 commit을 push해서 작업을 마무리한다. 

    $ git push origin master

     

    참고: https://mystria.github.io/archivers/recovery-missing-commit

    댓글

Designed by Tistory.