Git commands(branch, checkout, update 및 pull error 해결)
- git branch <new branch name> : 새 브랜치 생성
- git branch -a : local, remote의 branch 목록을 전부 출력.
- git checkout <branch name> : 현 작업공간(현 branch)에서 <branch name>으로 이동
- git remote update : remote에서의 변경 사항을 갱신
Error 원인 및 해결법
사례1 : git pull <branch name> 할 때 다음과 같은 에러가 뜸.
error: The following untracked working tree files would be overwritten by checkout:
.idea/.gitignore
.idea/inspectionProfiles/profiles_settings.xml
.idea/modules.xml
.idea/vcs.xml
.idea/xxx.iml
Please move or remove them before you merge.
untrack 되는 파일들을 pull 하려고 할 때
로컬에 있는 파일들이 덮어씌워주기 때문에 경고가 생기는 케이스다.
.idea/.gitignore
.idea/inspectionProfiles/profiles_settings.xml
.idea/modules.xml
.idea/vcs.xml
.idea/xxx.iml
Please move or remove them before you merge.
untrack 되는 파일들을 pull 하려고 할 때
로컬에 있는 파일들이 덮어씌워주기 때문에 경고가 생기는 케이스다.
untrack할 파일들을 미리 .gitignore에 리스팅해두고 커밋했어야했지만
그러지 않았기 때문에 생긴다.
이 파일들이 속해있는 폴더 .idea 폴더는 IDE에서는 보이지 않지만
파일탐색기를 타고 들어가보면 다음과 같이 존재한다.
.idea는 프로젝트의 메타데이터이기 때문에
프로그래머가 직접 수정할일이 없어서 IDE 프로젝트 트리에는 보여주지 않지만
Git으로 관리할 때는 여전히 관리 대상이다.
Git으로 관리할 때는 여전히 관리 대상이다.
보통 .idea는 untrack 되는 파일로, .gitignore의 대상이다.
이미 .idea를 포함한채로 commit 했기 때문에
다시 .gitignore에 포함시키려면 별도의 작업이 필요하다.
이 작업에 대해서는 다음 포스팅을 참고한다.
사례2 : git pull <branch name> 할 때 다음과 같은 에러가 뜸.
다른 컴퓨터에서 작업한 내용을 집에서 pull받아서 하거나
error: Your local changes to the following files would be overwritten by merge:
Please, commit your changes or stash them before you can merge.
error: The following untracked working tree files would be overwritten by merge:
Please move or remove them before you can merge.
또는 반대의 경우에 자주 쓰는데,
나는 동시에 같은 기능을 작업하지는 않기 때문에 가장 최근에 사용한 장소의 내용을
나는 동시에 같은 기능을 작업하지는 않기 때문에 가장 최근에 사용한 장소의 내용을
pull받아서 덮어 씌우는 것이 보통이다.
1 git stash -> staging 단계에 올려만 두고
2 git pull -> remote 저장소의 내용을 받아온다.

댓글
댓글 쓰기