본문 바로가기
Dev/CS

[Git] Pull 에러 해결하기 "Please commit your changes or stash them before you merge."

by jusep 2024. 7. 24.
git pull

 

을 했더니 다음과 같은 에러가 나왔다.

 

error: Your local changes to the following files would be overwritten by merge: apps/home/insert.py 

Please commit your changes or stash them before you merge. 

Aborting

 

- 원인

문제의 원인은 원격 저장소에서 pull 할때 로컬에 수정한 파일이 존재하기 때문이다.

예를 들어 팀 프로젝트 파일을 pull 하는 것을 까먹고, 로컬에서 프로젝트 파일을 수정하던 중 원격 저장소 파일을 pull  하게 되면 이런 에러가 나타난다.

 

- 해결방법

1. 로컬 내 수정 사항을 임시 공간으로 옮긴다

git stash

 

2. 원격 저장소를 pull 한다.

git pull origin main

 

 

끄아아앙

댓글