Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
git [2016/05/13 16:04] – [3-way merge] ledyxgit [2021/02/07 03:15] (current) – external edit 127.0.0.1
Line 1: Line 1:
 = Git = = Git =
  
-참고 +  * 참고 
-  https://git-scm.com/book/ko/v2 + 
-  https://backlogtool.com/git-guide/kr/ +https://git-scm.com/book/ko/v2 
-  https://rogerdudler.github.io/git-guide/index.ko.html+https://backlogtool.com/git-guide/kr/ 
 +https://rogerdudler.github.io/git-guide/index.ko.html
  
 {{tag>Git 형상관리}} {{tag>Git 형상관리}}
Line 52: Line 53:
 <sxh bash> <sxh bash>
 git add <FILE 이름> git add <FILE 이름>
 +</sxh>
 +
 +==== 모든 비어있는 디렉토리 추가 ====
 +<sxh bash>
 +git clean -nd | sed s/'^Would remove '// | xargs -I{} touch "{}.keep"
 </sxh> </sxh>
  
Line 99: Line 105:
  
 == Branch 병합 == == Branch 병합 ==
 +^  merge                                      rebase                              ^
 +|  모든 이력 남음.\\ (정확한 이력 저장 용도)  |  이력이 단순해짐.\\ (통합 이력 용도)  |
 +
 +  * 적절한 사용 예
 +    * https://backlogtool.com/git-guide/kr/stepup/stepup1_4.html
 +
 +
 +=== merge ===
 https://git-scm.com/book/ko/v2/Git-%EB%B8%8C%EB%9E%9C%EC%B9%98-%EB%B8%8C%EB%9E%9C%EC%B9%98%EC%99%80-Merge-%EC%9D%98-%EA%B8%B0%EC%B4%88 https://git-scm.com/book/ko/v2/Git-%EB%B8%8C%EB%9E%9C%EC%B9%98-%EB%B8%8C%EB%9E%9C%EC%B9%98%EC%99%80-Merge-%EC%9D%98-%EA%B8%B0%EC%B4%88
  
Line 104: Line 118:
  
 <sxh bash> <sxh bash>
-git merge <Branch 이름>+git merge <Branch 이름> [<commit>
 + 
 +#<commit> 
 +## --ff    (default, fast-forward) : 병합 흔적 남지 않음. 
 +## --no-ff (non-fast-forward)      : 병합 흔적 남음.
 </sxh> </sxh>
  
-== 종류 == +==== 종류 ==== 
-=== fast-forward ===+===== fast-forward =====
 조상 Brunch를 **"master"**, \\ 병합하려는 Brunch를 **"hotfix"**라고 할 때, 조상 Brunch를 **"master"**, \\ 병합하려는 Brunch를 **"hotfix"**라고 할 때,
  
Line 137: Line 155:
 </sxh> </sxh>
  
 +**☞ 병합 흔적이 Commit graph에 남지 않는다.**
  
-=== 3-way merge ===+ 
 +===== 3-way merge =====
 조상 Brunch를 **“master”**, 조상 Brunch를 **“master”**,
 병합하려는 Brunch를 **“issues”**라고 할 때, 병합하려는 Brunch를 **“issues”**라고 할 때,
Line 149: Line 169:
  
  
- +==== 충돌 해결 ====
-=== 충돌 해결 ===+
 충돌이 발생하면 **(<Branch 이름>|MERGING)**으로 표시됨. 충돌이 발생하면 **(<Branch 이름>|MERGING)**으로 표시됨.
   * 충돌난 파일을 열고, 편집 후 Index 추가 및 Commit.   * 충돌난 파일을 열고, 편집 후 Index 추가 및 Commit.
  
-=== 변경/충돌 내역 확인 ===+==== 변경/충돌 내역 확인 ====
 **※ 만약 [[#로컬 저장소 갱신 | git pull]] 명령을 이용했다면 알기 어려움.** **※ 만약 [[#로컬 저장소 갱신 | git pull]] 명령을 이용했다면 알기 어려움.**
  
Line 164: Line 183:
 git diff <원래 Branch> <비교 대상 Branch> git diff <원래 Branch> <비교 대상 Branch>
 </sxh> </sxh>
 +
 +
 +=== rebase ===
 +
 +==== Branch 이력 확인하면서 병합 ====
 +<sxh bash>
 +git rebase <branch 이름>
 +
 +git rebase <option>
 +#<option>
 +## --continue : Conflit 발생시 해결 후 계속 작업 진행.
 +## --skip     : 강제 병합.
 +## --abort    : Conflict 발생시 취소.
 +</sxh>
 +
 +==== Commit 내역 병합 ====
 +<sxh bash>
 +git rebase -i <revision>
 +#<revision>
 +## 이어서 "~ 혹은 ^"를 붙이면 개수만큼 되돌림.
 +
 +#지정한 <revision>과 최근 Commit을 병합하여 새로운 Commit 생성.
 +</sxh>
 +
 +===== 관례 =====
 +  * 남기는 Commit message 앞에는 접두어로 **pick** 붙인다.
 +  * 없애는 Commit message 앞에는 접두어로 **fixup** 붙인다.
 +  * **Commit SHA-1 Checksum 값**은 꼭 남겨야 한다.
 +  * 기존의 Commit message를 수정하지 않는다.
  
  
Line 271: Line 319:
 git commit --amend git commit --amend
 </sxh> </sxh>
 +
 +
 +== Untracking files 삭제 ==
 +
 +<sxh bash>
 +git clean <option> [--dry-run]
 +
 +#<option>
 +## -f : 파일만
 +## -fd : 파일 & 디렉토리 전부
 +
 +#[--dry-run] : 모의 실행
 +</sxh>
 +
  
  
Line 307: Line 369:
 # URL 대신 로컬 저장소도 복제 가능! # URL 대신 로컬 저장소도 복제 가능!
 </sxh> </sxh>
 +
 +=== 특정 Directory pull ===
 +<sxh bash ; highlight:[4]>
 +// pull 대상 Directory 생성하고
 +git init
 +git remote add -f origin URL
 +git config core.sparseCheckout true
 +echo "원하는 Directory 이름" > .git/info/sparse-checkout
 +git pull origin master
 +</sxh>
 +
  
  
Line 361: Line 434:
 <code bash> <code bash>
 # Shell path (64x 기준) # Shell path (64x 기준)
-C:\Program Files\Git\bin\sh.exe --login -i+"C:\Program Files\Git\bin\sh.exe-login -i
 </code> </code>
git.1463151878.txt.gz · Last modified: 2021/02/07 03:15 (external edit)