본문 바로가기
새우의 테크/troubleshooting

[Git] fatal: branch could be both a local file and a tracking branch.

by 오새우 2022. 9. 21.

Git checkout 을 하던 중 다음과 같은 에러가 발생했다. 

찾아보니 원래 git checkout은 세 가지 역할을 가진다. 

  • if it's local branch or explicit remote branch, switch to it.
  • if it's a tracked path, reset it
  • if it's a remote branch, create a tracking branch and switch to it.

(Reference: https://stackoverflow.com/questions/25322335/git-change-branch-when-file-of-same-name-is-present

 

그래서 동일 이름의 폴더와 브랜치가 있어서 git checkout 커맨드가 ambiguous 했던 것 같다. 

git checkout branch_name -- 으로 하면 된다고 한다. 

역으로 파일을 지정하고 싶으면 -- 뒤에 넣으면 되는 것 같다. 

 

댓글