E D R , A S I H C RSS

Git For The Real World


1. Introduction

  • Git의 명령어를 아는 것보다 중요한 것은, 실제 상황에서 언제 어떤 상황에서 Git의 어떤 기능을 써야하는지 아는 것이다. 실제 활용 사례 및 방법을 연구할 필요가 있다.
  • 해당 페이지의 이름은 아래 블로그 포스트에서 따왔다.

2. rebase vs merge

3. commit log


3.1. commit log graph로 보기

console에서 commit log를 보다 보면 가끔 이 커밋의 부모가 누구인지 중요할때가 있다. 이런 경우 github나 기타 gui에서 보여주는 그래프 기능이 절실하게 필요해 질때가 있다. 사실 이 graph기능은 이미 있다.

$ git log --graph

이 명령의 문제는 한 커밋에 대한 메세지가 여러줄을 차지하기 떄문에 전체적인 그래프를 보기 힘들다는데에 있다. 이럴때에는 <del>oneline옵션을 사용하면 된다. 또한 브랜치 명이나 태그명을 보이게 하려면 </del>decorate옵션을 사용하면 된다. 색상이 밋밋하다면 --format옵션을 통해 나름의 포맷을 지정할수 있다. 이같은 옵션을 적용하여 만든 명령은 다음과 같다.


$ git  log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all

이를 매번 그래프 기능이 필요할때마다 넣는것은 매우 어려운 일이기 때문에 ~/.gitconfig파일에 다음과 같이 기록하여 별칭을 지정해 둘수 있다.

 
[alias]
    graph = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all

4. bisect

5. rebase --interactive

만약 rebase -i 를 써보지 않았다면, Git의 진짜 위력을 모르는 것일수도 있다. 여러분이 쌓아올린 커밋을 업스트림하기 전에 다시 한 번 재고하고, 커밋들을 정리해보는 것은 어떨까.

아래는 해당 명령어 입력 시에 에디터에 보여지는 매뉴얼이다.
# Rebase (some hash)
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

TBD


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:18
Processing time 0.0344 sec