
git switch branch-name나 git checkout branch-name 하려고 하면 아래와 같은 에러를 만나게 됩니다.error: Your local changes to the following files would be overwritten by checkout:
...
Please commit your changes or stash them before you switch branches.
Abortinggit add .;git commit -m 'commit message'
git switch developgit stash입니다.git stash
git switch -c feature/new
git stash popgit stash - 현재까지의 수정사항을 임시 저장합니다. (저장 후에 git status로 체크하면 nothing to commit, working tree clean 출력)git switch -c feature/new - 현재의 branch를 기준으로 feature/new branch를 생성합니다.git stash pop - 가장 최근의 stash를 불러오고 해당 stash는 바로 삭제합니다.git stash와 git stash pop이라고 볼 수 있습니다.git stash는 아직 커밋할 준비가 되지 않은 변경사항을 저장할 수 있도록 도와주는 매우 유용한 명령어입니다. 변경사항을 저장한 후 나중에 다시 변경사항으로 돌아올 수 있습니다.git stash pop을 사용하여 stash의 가장 최근에 저장된 변경 사항을 제거하고 작업 영역에 다시 적용합니다.git stash pop과는 다르게 git stash apply를 사용하면 stash list에서 제거하지 않고 stashed된 모든 것을 적용할 수 있습니다. 이는 특정 stash를 여러 곳에 적용하고자 할 때 유용하게 사용 가능합니다.git stash와 git stash pop를 주로 사용합니다.git stash pop과 git stash apply의 차이 - git stash pop은 불러오고 삭제되고, git stash apply는 불러오고 stash list는 그대로 유지됩니다.git stash list를 통해서 여러 개의 stash를 확인할 수 있으나, 일반적으로는 하나의 stash를 git stash를 통해 저장하고 git stash pop을 통해 불러오고 삭제하는 작업을 주로 사용합니다.git stash drop stash@{0} → 특정 stash 삭제git stash clear → 전체 stash 삭제git stash pop이나 git stash apply를 통해 가져오지 않고 삭제하면 변경사항도 같이 사라지게 됩니다.