Skip to content

Instantly share code, notes, and snippets.

@SeonghuiChoe
Last active May 17, 2017 12:41
Show Gist options
  • Save SeonghuiChoe/a46a86ce9c5deeb658736efa423e2a53 to your computer and use it in GitHub Desktop.
Save SeonghuiChoe/a46a86ce9c5deeb658736efa423e2a53 to your computer and use it in GitHub Desktop.
git and github

merge

다른 사람의 업데이트 이력을 내 저장소에도 갱신

file pull and merge origin/master 다른파일 같은파일
file만 수정 pull and merge 문제없이 pull Please commit your changes or stash them
before you can merge. Aborting
file을 수정하고
commit
pull and merge 바로 commit editor실행되며
merge기본 형식의 message가 미리 적힌 상태 
CONFLICT (content): Merge conflictm
different commits each.
both modified:   README.md

both modified

<<<<<<< HEAD (my local branch name)
=======
>>>>>>> 8c25ab8cf03ee6f86da9fcc1b9cdbc78e3f2f826 (commit hash)

로컬 저장소 파일과 원격 저장소 파일이 충돌이 났을 때 저 모양을 볼 수 있다.
===== 로 구분된 윗 부분이 로컬 저장소, 아랫 부분이 원격 저장소의 변경 내용이라는 점!

여기서 직접 수정이 가능하지만 로컬 저장소의 변경사항 또는 원격 저장소의 변경사항을 선택 할 수 있다.

  • git checkout --theirs file: 로컬 저장소의 변경사항을 선택 (git checkout -3 file)
  • git checkout --ours file: 원격 저장소의 변경사항을 선택 (git checkout -2 file)

직접수정 or 로컬 저장소선택 or 원격 저장소선택 을 하게되면 git status를 쳤을때 아무 변화가 없다.
여기서 commit을 하고 merge작업을 계속하면 된다.

  • git commit: commit editor가 실행, Merge branch 'master' of ...이런 형식의 message가 미리 적힌 상태이다.
  • git commit -m "merge된 commit의 message" : 내가 적은 message로 merge commit이 생성
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment