개요
코드 변경사항이 발생한 경우 branch 이동이나 원격 저장소의 코드 병합을 하기 위해서는 commit을 해야 하는데, 종종 commit을 하기 애매한 상황이 있다.
이런 경우 git의 stash 기능을 사용해서 코드 변경사항을 임시저장하고 진행하면 되는데
이때 신규 파일의 경우에는 git의 관리 대상이 아니기 때문에 (한 번은 commit을 해야 함) 그냥 stash 명령어를 수행하면 그대로 날라가게 된다.
만약 stash 할 때 신규 파일까지 임시저장 하려면 아래 명령을 사용하면 된다.
git stash --include-untracked
그러나 이 방법을 모르고 stash를 한 경우에는 아래 방법대로 없어진 파일을 복구하기를 추천한다 !
해결 방법
안타깝게도 git에는 reset을 잘못한 경우에 복구할 수 있는 기능이 있지만, stash 하다가 파일이 없어진 경우에 대한 기능은 없는 것 같았다 (내가 못 찾은 것 일수도 있지만)
하지만 IDE의 로컬 히스토리 기능을 사용하면 Stash 이전에 작업하던 파일 내용을 확인할 수 있고,
수작업으로 파일을 새로 만들어서 복구할 수 있다.
stash로 없어진 파일이 많다면 수작업이 조금 힘들 수도 있지만
그래도 다시 코딩하는 것을 생각해 보면 너무 감사한 기능이다..
IDE 로컬 히스토리 확인 방법은 아래 순서대로 진행하면 된다.
1. 특정 경로를 마우스로 지정 > 파일 > 로컬 기록 > 기록 표시
2. 로컬 기록 확인
'Trouble Shooting > Git' 카테고리의 다른 글
[Git] Clone/Pull 진행 시 로그인 에러 해결 (0) | 2022.07.20 |
---|