Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

GitForTheRealWorld: Difference between revisions

From ZeroWiki
imported>qa22ahj
No edit summary
(Repair batch-0002 pages from live compare)
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__TOC__
= Introduction =
= Introduction =
* Git의 명령어를 아는 것보다 중요한 것은, 실제 상황에서 언제 어떤 상황에서 Git의 어떤 기능을 써야하는지 아는 것이다. 실제 활용 사례 및 방법을 연구할 필요가 있다.
* Git의 명령어를 아는 것보다 중요한 것은, 실제 상황에서 언제 어떤 상황에서 Git의 어떤 기능을 써야하는지 아는 것이다. 실제 활용 사례 및 방법을 연구할 필요가 있다.
Line 10: Line 11:


  $ git log --graph
  $ git log --graph
이 명령의 문제는 한 커밋에 대한 메세지가 여러줄을 차지하기 떄문에 전체적인 그래프를 보기 힘들다는데에 있다. 이럴때에는  
이 명령의 문제는 한 커밋에 대한 메세지가 여러줄을 차지하기 떄문에 전체적인 그래프를 보기 힘들다는데에 있다. 이럴때에는  
  --oneline
  --oneline
옵션을 사용하면 된다. 또한 브랜치 명이나 태그명을 보이게 하려면 {{{--decorate}}}옵션을 사용하면 된다. 색상이 밋밋하다면 {{{--format}}}
옵션을 사용하면 된다. 또한 브랜치 명이나 태그명을 보이게 하려면 --decorate옵션을 사용하면 된다. 색상이 밋밋하다면   --format옵션을 통해 나름의 포맷을 지정할수 있다. 이같은 옵션을 적용하여 만든 명령은 다음과 같다.
옵션을 통해 나름의 포맷을 지정할수 있다. 이같은 옵션을 적용하여 만든 명령은 다음과 같다.
 
  $ git  log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(re    set) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(r    eset)' --all
 
이를 매번 그래프 기능이 필요할때마다 넣는것은 매우 어려운 일이기 때문에 {{{~/.gitconfig}}}파일에 다음과 같이 기록하여 별칭을 지정해 둘수 있다.
  $ 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
  [alias]
 
     graph = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(re    set) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(r    eset)' --all
이를 매번 그래프 기능이 필요할때마다 넣는것은 매우 어려운 일이기 때문에  
= 항목 추가 바람 =
<code>/.gitconfig</code>
파일에 다음과 같이 기록하여 별칭을 지정해 둘수 있다.
 
  &#91;alias&#93;
     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
= bisect =
= 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
 
----
----

Latest revision as of 00:16, 27 March 2026

Introduction

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

rebase vs merge

commit log

commit log graph로 보기

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

$ git log --graph

이 명령의 문제는 한 커밋에 대한 메세지가 여러줄을 차지하기 떄문에 전체적인 그래프를 보기 힘들다는데에 있다. 이럴때에는

--oneline

옵션을 사용하면 된다. 또한 브랜치 명이나 태그명을 보이게 하려면 --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

bisect

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