깃 체크아웃 시 발생하는 에러

» Error

error: Your local changes to the following files would be overwritten by checkout:

에러 내용

error: Your local changes to the following files would be overwritten by checkout:
...
Please commit your changes or stash them before you switch branches.

에러 원인

다른 브랜치로 이동하기 전 작업하고 있던 브랜치에서 변경사항이 있는데, 제대로 커밋(저장)하지 않아 발생하는 오류

해결 방법

해당 브랜치를 커밋(commit)하거나 임시저장(stash)

git stash # 기존 브랜치에서 임시 저장
git checkout <이동할 브랜치> # 브랜치 이동해서 작업
git checkout <원래 작업하던 브랜치> # 다시 돌아와서
git stash pop # 삭제