반응형

출처 

http://unix.stackexchange.com/questions/44266/how-to-colorize-output-of-git

git의 출력에 색을 입히는 방법?

git(또는 명령어)에 대한 출력에 색을 입히는 방법이 있을까요?

다음은 예시입니다.

not stage

baller@Laptop:~/rails/spunky-monkey$ git status
# On branch new-message-types
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   app/models/message_type.rb
#
no changes added to commit (use "git add" and/or "git commit -a")
baller@Laptop:~/rails/spunky-monkey$ git add app/models

stage

baller@Laptop:~/rails/spunky-monkey$ git status
# On branch new-message-types
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   app/models/message_type.rb
#

출력은 같아보입니다만, 정보는 완전히 다릅니다. 파일이 위는 unstaged 상태이고 밑은 stage로 이동한 상태입니다.

이 출력에 색을 입히는 방법이 있을까요? 예를들어 unstage된 파일은 빨간색, stage된 것은 녹색으로요?

또는 Changes not staged for commit:는 빨간색, # Changes to be committed:은 녹색으로요?

Ubuntu에서 작업중입니다.

구글링해서 잘 작동하는 답변을 찾았습니다 : git config --global --add color.ui true

하지만 명령어 출력에 색을 추가하는 더 일반적인 해결책을 알고 싶습니다.

----

4 개의 답변 중 1개의 답변만 추려냄.

~/.gitconfig 파일에서 [color] 섹션을 생성합니다. 예를 들면 다음처럼 하실 수 있습니다.

[color]
  diff = auto
  status = auto
  branch = auto
  interactive = auto
  ui = true
  pager = true
또한, 어떤 부분에 색을 입히길 원하는 지도 제어하실 수 있습니다. 예를 들면,
[color "status"]
  added = green
  changed = red bold
  untracked = magenta bold

[color "branch"]
  remote = yellow
이를 통해 시작하시길 바랍니다. 당연히 색 입히는 걸 지원하는 터미널이 필요할 것입니다.


반응형

+ Recent posts