git merge front
CONFLICT (add/add): Merge conflict in front-end/.gitignore
CONFLICT (modify/delete): front-end/node_modules/.package-lock.json deleted in HEAD and modified in front. Version front of front-end/node_modules/.package-lock.json left in tree.
Automatic merge failed; fix conflicts and then commit the result.
충돌 1: main 브랜치와 front 브랜치에서 각각 .gitignore
을 추가함
충돌 2: front 브랜치에서는 package-lock.json
파일이 수정되었으나, main 브랜치에서는 삭제됨
git status
Git 변경 내역을 확인합니다.
<<<<<<< HEAD
# 기존 HEAD 브랜치의 내용
node_modules/
=======
# front 브랜치의 내용
node_modules/
dist/
>>>>>>> front
>>>>>> HEAD
, ======
,<<<<<< front
충돌 표시 문자 제거git checkout front front-end/node_modules/.package-lock.json
front 브랜치의 변경 사항을 main 브랜치에 유지합니다.
git add .
git commit -m "Merge front branch"
git push
충돌이 발생한 파일은 자동 병합이 불가능하므로, 따로 commit을 해줘야합니다.
만약 GitHub와 연결된 로컬 레포지토리를 삭제 후 다시 clone을 받은 상태라면
원격 저장소의 브랜치를 가져와 작업해야 합니다.
git fetch --all
.gitignore 파일을 명령어를 통해 가져오는 것도 가능합니다. 하지만, 권장되지 않습니다.
.gitignore과 같은 설정 파일은 Git이 추적하지 않도록 설정하는 중요한 파일이기 때문입니다.
수동으로 확인하는 것이 더 안전하다고 합니다.