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

리로린·2022년 8월 21일

git 에러 사항

목록 보기
1/2
post-thumbnail

![]

다음과 같이 git 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.
Aborting

stash에 임시로 올리거나 commit 하면 해결되는 오류이다.

현 로컬 내용이 삭제되어도 상관이 없을 경우

git reset --hard HEAD~1

위와 같이 가장 최근 commit으로 되돌린다.
만약 stash 업로드가 필요할 경우
아래와 같이 진행한다.

# 현재 로컬 Staging 영역에 있는 파일의 변경사항을 stash에 업로드 합니다.

$ git stash

# 아래 명령어와 같이 원격 저장소의 master에서 pull을 하거나, git checkout master와 같이 브랜치를 바꿀 수 있습니다. 

$ git pull origin master

# stash 명령어로 스택에 넣어둔 변경 사항을 적용하고, stash에서 pop을 통해 제거 한다. 


$ git stash pop
profile
리로린의 블로그

0개의 댓글