SW 개발/Git
[Git] Pull 또는 Checkout 시 에러 해결하기: error: Your local changes to the following files would be overwritten by checkout:
DATA101
2022. 1. 12. 10:15
728x90
반응형
❗ 에러 상황
checkout (branch 이동) 또는 pull 시 발생
📑 에러 메시지
error: Your local changes to the following files would be overwritten by checkout:
...
Please commit your changes or stash them before you switch branches.
Aborting
✨ 해결 방법
Step 1) 변동사항 스택 내 저장
stash: 현재 Staging 영역 내 파일의 변동사항을 스택에 넣어두기
git stash
Step 2) checkout 또는 pull 시행
checkout 희망 시
git checkout [변경할 branch 이름]
pull 희망 시
git pull origin [branch 이름]
Step 3) 스택 내 데이터 삭제
git stash pop
Advanced) 요약된 명령어
checkout 희망 시
git stash && git checkout [변경할 branch 이름] && git stash pop
pull 희망 시
git stash && git pull origin [branch 이름] && git stash pop
포스팅 내용에 오류가 있다면 아래에 댓글 부탁드립니다.
그럼 오늘도 즐거운 하루 보내시길 바랍니다 :)
고맙습니다.
728x90
반응형