본문 바로가기
git

The following untracked working tree files would be overwritten by merge: Please move or remove them before you merge.

by 오젼 2021. 2. 5.

ㅠㅠ.. git push, pull하다가 낸 오류

git pull이 fetch + merge 과정인데, merge할 때 untracked 파일들이 overwritten될 수 있다고 경고한다.

해석한 것이 맞는진 모르겠지만, fetch까지는 OK, merge에서 error여서 아래 해결방법이 먹혔던 것 같다.

ㅠㅠ왜 오류난 건진 아직도 제대로 이해하지 못했지만,, 어쨌든 아래 방법이 먹히니 다음부터 stash 잘 하고 오류 잘 해결할 수 있도록 할 것..

 

!!!오류 수정 시도 하기 전에 git stash 해놓을 것!!!

git stash하면 현재 상태가 저장됨.

나중에 git stash list로 stashID 확인하고 해당 상태로 돌아갈 수 있도록 백업해두기!!!! 

helloinyong.tistory.com/202

 

[2019.09.13] git stash 사용법 - 현재 상태를 저장해보자

최근에 A브랜치에서 작업을 완료 후 pull Request를 올렸다. 그리고 새로운 기능의 작업을 위해 B브랜치를 따서 쭉 작업하는 중, A브랜치에서 작업한 내용의 코드 리뷰를 받아 수정할 사항이 생겼다

helloinyong.tistory.com

 

이후 수정

github.com/avast/retdec/issues/92#issuecomment-501632315

 

git pull error: The following untracked working tree files would be overwritten by merge · Issue #92 · avast/retdec

Pulling a new master ends with the following error: $ git pull error: The following untracked working tree files would be overwritten by merge: deps/googletest/CMakeLists.txt deps/libdwarf/CMakeLis...

github.com

-->이 분 댓글로 해결..

git fetch --all
git reset --hard origin/{{your branch name}}

 

branch name은 "git branch" 명령어로 확인 가능.

내경우 main이었기 때문에

git fetch --all

git reset --hard origin/main으로 해결.

 

git fetch --all 하면 깃허브에 있던 상태로 다시 다 돌아가는 것 같다. stash 안해뒀음 파일 다 날렸을 뻔ㅠㅠ....

stash를 습관화 하자..

'git' 카테고리의 다른 글

git clean은..완전히 알 때까지 절대 사용ㄴㄴ..  (0) 2021.02.05
git add, commit, push 취소  (0) 2021.02.05

댓글