본문 바로가기

개발중/git

git checkout 에러 : Your local changes to the following files 해결

728x90
반응형

 

나는 checkout 을 하려고 하는데 자꾸만 아래와 같은 에러가 발생했다. 😂

 


 

soobi@DESKTOP-Q26RDFJ MINGW64 ~/git/poms (feature/sb/work)
$ git checkout main
error: Your local changes to the following files would be overwritten by checkout:
        vue/src/views/crowd-sourcing/crowd-sourcing-mng/worker/components/insertPopup.vue
Please commit your changes or stash them before you switch branches.
Aborting

 


 

git stash

 

git stash 를 활용해 해결을 하였다.

 

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

이를 통해 아직 완료하지 않은 일을 commit 하지 않고 나중에 다시 꺼내와 마무리할 수 있다.

 

  • git stash 명령을 사용하면 워킹 디렉토리에서 수정한 파일들만 저장한다.
  • stash 란 아래에 해당하는 파일들을 보관해두는 장소 이다.
    • Modified이면서 Tracked 상태인 파일
      • Tracked 상태인 파일을 수정한 경우
      • Tracked: 과거에 이미 commit하여 스냅샷에 넣어진 관리 대상
    • 상태의 파일Staging Area에 있는 파일(Staged 상태의 파일)
      • git add 명령을 실행한 경우
      • Staged 상태로 만들려면 git add 명령을 실행해야 한다.
      • git add는 파일을 새로 추적할 때도 사용하고 수정한 파일을 Staged 상태로 만들 때도 사용한다.

 


git stash  save

 

git stash save 명령어를 이용하면 새로운 stash 가 만들어진다.

이 과정을 통해 workiong directory 는 깨끗해진다.

 


728x90
반응형