error: Your local changes to the following files would be overwritten by checkout
checkout 할 때 위와 같이 error가 발생했다.
merge 또는 switch branch 이전에 변경사항을 commit 하거나 stash 하면 해결된다고 한다.
stash를 통해 해결하고 checkout을 했다.
$ checkout develop
develop 브랜치를 가져오려고 checkout develop을 했더니 최신 commit 된 develop 브랜치가 아닌 이상한 develop 브랜치가 기존 파일이 사라져버렸다.
$ git remote update // 원격 저장소 갱신 $ git branch -r // 원격 저장소의 리스트 확인 $ git checkout -t origin/develop // 해당 브랜치로 checkout
- $ git checkout -t : 원격 저장소의 branch 이름과 동일한 이름의 로컬 저장소 branch를 생성하고, 해당 branch로 checkout 한다.
- $ git checkout -b : branch 이름을 변경해서 가져온다.
- $ git checkout -f : 문제가 발생해도 강제로 branch 이름과 동일한 로컬 저장소 branch를 생성하고, 해당 branch로 checkout 한다.