Flutter

[flutter] git checkout & pull 오류

에릭 Kim 2022. 7. 18. 23:38
반응형

프로젝트 내에서 git checkout (branch) 또는 git pull origin (branch)을 했을 때 다음과 같은 오류를 만날 수 있습니다. 

 

 

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

 

에러 자체는 브랜치를 변경하기 전에 수정 사항을 커밋하거나 stash 해라고 하는 말이지만, 자신이 커밋하고자 하는 브랜치가 아닌데 커밋을 해야 하나 생각이 들 수 있습니다. 이런 때는 git stash 명령어를 사용하여 해결할 수 있습니다. 

 

git stash 명령어는 마무리 하지 않은 작업을 스택에 잠시 저장할 수 있도록 하는 명령어입니다.

git stash // 변경 사항을 스택에 저장

git pull origin (branch 이름) or git checkout (branch 이름) // checkout or push 

git stash pop // 변경 사항 적용 및 스택에 있는 데이터 삭제

사용법 : git stash && git pull origin (branch) or git checkout (branck) && git stash pop

 

 

 

반응형