서론(Introduction)
Push가 무사히 이루어지려면 'GitHub에 업로드 되어 있는 파일'과 '수정을 시작할 때 Local에 있던 파일'이 같아야합니다.
그렇지 않은 경우에 Push를 하면 충돌(Conflict)이 발생합니다(아래의 사진 참고). 이를 해결하는 방법을 배워보도록 하겠습니다.
In order for a successful push to occur, the "file uploaded on GitHub" and the "file present locally at the start of the modifications" need to be the same.
If they are different, pushing will result in a conflict (refer to the picture below). Let's learn how to resolve this issue.
Step 1.
'Cancel'을 클릭하세요.
Click 'Cancel'
Step 2.
Pull을 진행하세요. 그러면 Stage가 취소되면서 아래와 같은 화면을 확인할 수 있습니다.
Execute the command "pull". Then you will be able to see the following screen where the staging will be canceled.
초록색 상자 안에는 Local에서 수정한 내용을 보여주고 파란색 상자 안에는 GitHub의 내용을 보여줍니다.
The green box displays the modifications made locally, while the blue box displays the content from GitHub.
Step 3.
3가지 선택지가 있고, 원하시는 것을 클릭하시면 됩니다.
Accept Current Change: Local에서 수정한 내용만 받아들이고 GitHub의 내용은 삭제합니다.
Accept Incoming Change: Local에서 수정한 내용은 삭제하고 GitHub의 내용만 받아들입니다.
Accept Both Changes: Local과 GitHub의 내용을 모두 받아들입니다. 가장 안전합니다.
There are three options, and you can click the one you prefer:
Accept Current Change: Only the modifications made locally will be accepted, and the content on GitHub will be discarded.
Accept Incoming Change: The modifications made locally will be discarded, and only the content on GitHub will be accepted.
Accept Both Changes: Both the local and GitHub contents will be accepted. This is the safest option.
Step 4.
예를 들어, 'Accept Both Changes'를 클릭하면 오른쪽과 같은 화면을 확인할 수 있습니다.
이제, 컴파일(혹은 저장)을 실행하세요.
For example, if you click on 'Accept Both Changes', you will be able to see a screen similar to the one on the right.
Now, execute the compilation (or saving).
Step 5.
Source control에서 'Merge Changes'에서 '+'버튼을 클릭하고 'Changes'에서도 '+'버튼을 클릭하세요. 그러면 오른쪽과 같은 화면처럼 모든 변경들이 Stage된 것을 확인할 수 있습니다.
In the source control, click on the '+' button in 'Merge Changes', and also click on the '+' button in 'Changes'. Then you will be able to see that all the changes have been staged, just like the screen on the right.
Step 6.
Commit & Push를 진행하세요.
이로써 충돌이 해결되었습니다.
Proceed with the command "Commit & Push".
Thus, the conflict has been resolved.
Tip. Merge Editor
Step 2에서 오른쪽 하단의 오류 메세지를 닫고 나면, 'Resolve in Merge Editor'버튼을 확인할 수 있습니다. 이 버튼을 클릭하여서 Merge를 진행할 수도 있습니다.
Once you close the error message in the bottom right corner during Step 2, you will notice the 'Resolve in Merge Editor' button. You can click on this button to proceed with the merge.