-
Notifications
You must be signed in to change notification settings - Fork 10
03. git 03
Dongwook Lee edited this page Jun 3, 2013
·
4 revisions
-
진행 요약
- branch
- 생성: git branch ${branch-name}
- 삭제: git branch -d ${branch-name}
- 예: 내용 수정 후 branch 이동
- 되는 경우, 안되는 경우
- start
- line1/line2 >> test.txt
- extra: line3/line4 add (with others)
- 'detached head' state
- (no branch) state
- git checkout origin
- 'line5' add (no branch)
- 'line6' add (master)
- git checkout -b ${branchname}
- git graph로 확인
- merge
- git은 merge 결과가 새로운 commit으로 추가된다
- 실패시 새로운 commit 추가 직전에 멈춤
- 주요 옵션 no-ff
- merge 취소에 대한 주요 법칙
- 누구가에게 merge 당한 commit object는 쉽게 취소가 되지 않는다.
- 상대의 내용에 영향을 주었기 때문에 상대 또한 작업을 해야한다.
- 누군가를 merge한 commit object는 취소할 수 있다.
- 상대의 내용에 영향을 준 건 아니기 때문에 merge commit을 취소하면 된다.
- 누구가에게 merge 당한 commit object는 쉽게 취소가 되지 않는다.
- merge 후 일부 브랜치 병합 없었던 일로 하기는 반드시 예제로 추가한다.
- merge 후 충돌이 나면: CONFLICT
-
git status로
You have unmerged paths.
메시지 확인이 가능하다. -
git ls-files -u
-
list conflicting blobs(3)
> git ls-files -u contents 100644 ee3ecd22c807354b4cea36b827e76c0285c9e401 1 contents 100755 4c5ac21ed599a93e7523bbc62ed928c18364d9b8 2 contents 100644 ecb08d9d0b10ee5bc16f1030da048596c90a7504 3 contents
-
-
git checkout --conflict=merge contents
> cat contents <<<<<<< ours print "ohaio" ======= print "hello" >>>>>>> theirs
-
- patch
- git format-patch -M
- git show --pretty=email
- rebase
- git rebase ${target-branch}
- git rebase --onto master server client
- clien - server > master
- branch 명을 쓰면 따라간다.
- git rebase --onto 1f3d63c HEAD feature-03
- git rebase --onto master server client
- from common parent, make patch in current branch
- apply the patch to the target branch
- conflict? (no branch)
- git rebase --continue
- git rebase --interactive
- todo: HEAD로 fast-forwarding하기
- git checkout master && git merge
- git rebase ${target-branch}
- cherry-pick
- git cherry-pick ${changeset}
-
git am
can be better than cherry-pick since it doesn't create a remote
- merge vs rebase
- rebase hell
- 특정 기능이 branch에 통합되어야 할 경우
- 깨끗한 history
- rebase의 위험성
- git pull
- = git fetch + git merge
- git clone ...-cloned
- git remote로 확인
- fetch로 여러 branch 가져오기?
- remote: cloned를 test에 등록하고 cloned에서 결과 가져오기
- 추적 브랜치 만들기
- git checkout -b hotfix-10280 cloned/hotfix-10280
- git clone의 경우 자동으로 추적 브랜치를 생성해 줌
- git pull --rebase
- pull merge 대신 rebase
- discuss: 과거 이력 수정하기
- git commit --amend 는 적합하지 않음
- answer? git rebase -i
- branch
-
실습
- "오래전 commit message" 수정하기
- git rebase -i