# 병합 충돌

원활한 분기 통합과 성공적인 끌어오기 요청 병합을 보장하기 위해 Git에서 병합 충돌을 식별하고 해결합니다.

Git은 종종 분기 간의 차이점을 해결하고 자동으로 병합할 수 있습니다. 일반적으로 변경 내용은 다른 줄 또는 다른 파일에 있으므로 Git은 도움 없이 병합할 수 있습니다. 때때로 충돌하는 변경 사항을 해결하는 데 도움이 필요합니다. 병합 충돌은 사용자가 동일한 파일의 동일한 줄을 다르게 변경하거나 한 사람이 파일을 편집하고 다른 사용자가 동일한 파일을 삭제할 때 종종 발생합니다.

병합 충돌은 Git이 유지할 충돌 콘텐츠의 버전을 안전하게 선택할 수 없으므로 병합 충돌을 차단합니다.
GitHub에서 끌어오기 요청을 병합하려면, 모든 병합 충돌을 먼저 해결해야 합니다. 끌어오기 요청에 비교 분기와 기본 분기 간에 병합 충돌이 있는 경우 충돌이 해결될 때까지 **병합 끌어오기 요청** 단추가 비활성화됩니다.

## 병합 충돌 해결

병합 충돌을 해결한다는 것은 분기가 병합된 후 표시되어야 하는 최종 콘텐츠를 선택하는 것을 의미합니다. 올바른 도구는 충돌 유형에 따라 달라집니다.

* 간단한 줄 충돌은 GitHub에서 해결되는 경우가 많습니다.
  [Resolving a merge conflict on GitHub](/ko/pull-requests/how-tos/merge-and-close-pull-requests/resolving-a-merge-conflict-on-github)을(를) 참조하세요.

* 더 복잡한 충돌은 로컬 클론에서 해결한 후 풀 요청 브랜치에 다시 푸시해야 합니다.
  [Resolving a merge conflict using the command line](/ko/pull-requests/how-tos/merge-and-close-pull-requests/resolving-a-merge-conflict-using-the-command-line)을(를) 참조하세요.

* Copilot 클라우드 에이전트에 대한 액세스 권한이 있고 해당 리포지토리에 대해 활성화되어 있는 경우, Copilot를 사용하면 병합 상자에서 충돌을 해결하는 데 도움이 됩니다.
  [GitHub Copilot 클라우드 에이전트 사용](/ko/copilot/how-tos/use-copilot-agents/cloud-agent/use-cloud-agent-on-github#resolving-merge-conflicts)을 참조하세요.

명령줄에서 Git은 병합을 자동으로 완료할 수 없는 경우를 알려줍니다. 충돌을 해결하고 그 해결 내용을 커밋하기 전까지는 병합 결과를 푸시할 수 없습니다.

```shell
$ git merge BRANCH-NAME
> Auto-merging styleguide.md
> CONFLICT (content): Merge conflict in styleguide.md
> Automatic merge failed; fix conflicts and then commit the result
```

## 추가 읽기

* [끌어오기 요청 병합](/ko/pull-requests/reference/pull-request-merges)
* [끌어오기 요청](/ko/pull-requests/reference/pull-requests)
* [Resolving a merge conflict using the command line](/ko/pull-requests/how-tos/merge-and-close-pull-requests/resolving-a-merge-conflict-using-the-command-line)
* [Resolving a merge conflict on GitHub](/ko/pull-requests/how-tos/merge-and-close-pull-requests/resolving-a-merge-conflict-on-github)