예쁜 Git 분기 그래프
나는 몇몇 책과 기사에 Git 브랜치와 커밋의 정말 예쁜 그래프가 있는 것을 본 적이 있다.Git 히스토리의 고품질 인쇄 가능 이미지를 만들려면 어떻게 해야 하나요?
업데이트: Git 질문의 Visualizing 브랜치토폴로지에 이 답변의 개량판을 올렸습니다.그것이 훨씬 더 적절하기 때문입니다.역사적인 이유로 이 답변을 남기는 것은 인정합니다만, 정말로 삭제하고 싶은 생각이 듭니다.
내 의견:제가 보통 쓰는 가명이 두 개 있어요~/.gitconfig
삭제:
[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all
lg2 = 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(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg = lg1
git lg
/git lg1
있어요.
★★★★★★★★★★★★★★★★★」git lg2
있어요.
(주: 이 질문에는 프락츠, 주밥스, 해리 리와 같은 훨씬 더 적절한 답변이 있습니다.)
여기에서는, 많은 회답이 훌륭합니다만, 에일리어스나 그 외의 것을 설정하지 않고, 간단한 1행 1점짜리 회답만을 희망하시는 분은, 이하를 참조해 주세요.
git log --all --decorate --oneline --graph
이 다 하는 .git log
항상 그렇지만 필요할 때는 꼭 기억해 두세요.
"A Dog" = git log --all --syslog --online --그래프
입력하신 경우
git config --global alias.adog "log --all --decorate --oneline --graph"
명령 프롬프트에서 한 번 실행하면
git adog
닫았다가 다시 열어도 프롬프트에서 확인할 수 있습니다.
텍스트 출력의 경우 다음을 시도할 수 있습니다.
git log --graph --abbrev-commit --decorate --date=relative --all
또는 다음 중 하나를 선택합니다.
git log --graph --oneline --decorate --all
또는 DAG 그래프를 그리기 위한 Graphviz 별칭입니다.
저는 개인적으로,gitk --all
및 를 참조해 주세요.
Gitgraph.js는 저장소 없이도 예쁜 Git 브랜치를 그릴 수 있습니다.브랜치나 커밋을 구성하는 JavaScript 코드를 작성하여 브라우저에 렌더링하기만 하면 됩니다.대화형 문서를 사용할 수 있습니다.
var gitGraph = new GitGraph({
template: "blackarrow",
mode: "compact",
orientation: "horizontal",
reverseArrow: true
});
var master = gitGraph.branch("master").commit().commit();
var develop = gitGraph.branch("develop").commit();
master.commit();
develop.commit().commit();
develop.merge(master);
★★★★★★★★★★★★★★★★★★★★★★★★.metro
★★★★★★★★★★★★★★★★★★:
또는 커밋 메시지, 작성자 및 태그 포함:
JSFiddle로 테스트합니다.
TikZ & PGF 위에 구축된 작은 LaTeX 패키지는 벡터 그래픽 커밋 그래프 등을 쉽게 만들 수 있습니다.
기존 리포지토리의 커밋 그래프를 자동으로 생성하는 것은 의 목적이 아닙니다. 생성되는 그래프는 교육 목적으로만 사용됩니다.
ASCII 커밋 그래프의 대안으로 Git 질문에 대한 답변을 위한 그래프를 만드는 데 자주 사용합니다.
- 마스터에서 오류를 수정하고 안정성이 낮은 브랜치에 통합하는 방법은 무엇입니까?
- git commit --amend는 정확히 어떻게 작동합니까?
- "git checkout origin/<branch>"를 실행한 후 Git에서 "Not current on any branch"라고 표시되는 이유는 무엇입니까?
- 마스터를 브랜치로 Marge하는 것과 브랜치를 Master로 Marge하는 것의 차이점은 무엇입니까?
- Git rebase --preserve-merges 실패
다음으로 단순 리베이스의 효과를 나타내는 그래프의 예를 제시하겠습니다.
\documentclass{article}
\usepackage{subcaption}
\usepackage{gitdags}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{\textwidth}
\centering
\begin{tikzpicture}
% Commit DAG
\gitDAG[grow right sep = 2em]{
A -- B -- {
C,
D -- E,
}
};
% Tag reference
\gittag
[v0p1] % node name
{v0.1} % node text
{above=of A} % node placement
{A} % target
% Remote branch
\gitremotebranch
[origmaster] % node name
{origin/master} % node text
{above=of C} % node placement
{C} % target
% Branch
\gitbranch
{master} % node name and text
{above=of E} % node placement
{E} % target
% HEAD reference
\gitHEAD
{above=of master} % node placement
{master} % target
\end{tikzpicture}
\subcaption{Before\ldots}
\end{subfigure}
\begin{subfigure}[b]{\textwidth}
\centering
\begin{tikzpicture}
\gitDAG[grow right sep = 2em]{
A -- B -- {
C -- D' -- E',
{[nodes=unreachable] D -- E },
}
};
% Tag reference
\gittag
[v0p1] % node name
{v0.1} % node text
{above=of A} % node placement
{A} % target
% Remote branch
\gitremotebranch
[origmaster] % node name
{origin/master} % node text
{above=of C} % node placement
{C} % target
% Branch
\gitbranch
{master} % node name and text
{above=of E'} % node placement
{E'} % target
% HEAD reference
\gitHEAD
{above=of master} % node placement
{master} % target
\end{tikzpicture}
\subcaption{\ldots{} and after \texttt{git rebase origin/master}}
\end{subfigure}
\caption{Demonstrating a typical \texttt{rebase}}
\end{figure}
\end{document}
Gitg는 Gitk와 GitX for GNOME(KDE 등에서도 동작)의 클론으로서, 예쁜 색상의 그래프를 나타내고 있습니다.
적극적으로 개발되고 있다(2012년 현재).시간순 또는 토폴로지로 커밋(그래프 노드)을 정렬하고 선택한 분기로 연결되지 않은 커밋을 숨길 수 있습니다.
대규모 저장소 및 복잡한 종속성 그래프에서 잘 작동합니다.
Linux-git 및 Linux-2.6 저장소를 표시하는 샘플 스크린샷:
HTML/Canvas를 사용하여 예쁜 Git 커밋 그래프를 생성할 수 있는 툴 하나를 작성했습니다.
또한 사용하기 쉬운 jQuery 플러그인을 제공합니다.
[기트허브] https://github.com/tclh123/commits-graph
미리 보기:
Sourcetree는 정말 좋은 것이다.이것은 보기 좋은 중간 크기의 이력 및 분기 그래프를 출력합니다: (다음은 실험적인 Git 프로젝트에서 브랜치를 보기 위해서만 수행되었습니다.)Windows 7+ 및 Mac OS X 10.6+를 지원합니다.
git-forest
1년 이상 사용해 온 훌륭한 Perl 스크립트입니다.또한 이 스크립트는 거의 사용하지 않습니다.git log
더 이상 직접 명령할 수 없습니다.
이 스크립트가 마음에 드는 것은 다음과 같습니다.
- 또한 유니코드 문자를 사용하여 그래프에 선을 그려 그래프 선을 보다 연속적으로 표시합니다.
- 할 수 .
--reverse
할 수 인 출력에서는 할 수 없습니다.git log
명령어를 입력합니다. - it it를 한다.
git log
를 취득하기 , 「커밋」에 모든 은, 「리스트를 합니다.git log
이 스크립트에도 전달할 수 있습니다.
에일리어스를 사용하고 있습니다.git-forest
음음음같 뭇매하다
[alias]
tree = "forest --pretty=format:\"%C(red)%h %C(magenta)(%ar) %C(blue)%an %C(reset)%s\" --style=15 --reverse"
단말기의 출력은 다음과 같습니다.
Git 로그를 예쁜 SVG 그래프로 변환하기 위한 웹 툴을 작성했습니다.
「 」의 출력을 .git log --pretty='%h|%p|%d'
「그래프」라고 하는 것입니다.
이 툴은 순수 클라이언트측이기 때문에 Git 데이터는 제 서버와 공유되지 않습니다.HTML + JavaScript를 로컬로 저장하고 "file:///" URL을 사용하여 실행할 수도 있습니다.Ubuntu 12.04(Precision Pangolin)의 Chrome 48과 Firefox 43에서 검증되었습니다.
임의의 페이지(블로그 스팟 블로그 엔진 포함!)에 직접 투고할 수 있는 HTML을 생성합니다.블로그 투고 중 일부를 참조하십시오.
http://bit-booster.blogspot.ca/
다음은 툴에 의해 생성된 샘플HTML 파일의 스크린샷입니다.
http://bit-booster.com/graph.html (툴)
쉘용 테이블처럼 깔끔한 Git 그래프 출력
그래프 트리 옆에 해시가 있는 경우
또는 추가 열에
편집: 모든 설명을 읽지 않고 바로 시작하시겠습니까?EDIT 6으로 이동합니다.
정보: 셸의 브랜치 컬러 버전에 대해서는, 제 2 회답(https://stackoverflow.com/a/63253135/)도 참조해 주세요.
이 질문에 대한 모든 답변에서 지금까지 조개껍데기에 대한 깨끗한 표와 같은 출력을 보여준 사람은 없었습니다.가장 가까운 답은 제가 출발한 고스피즈에서 온 대답입니다.
이 접근법의 핵심은 사용자에게 표시되는 트리 문자만 세는 것입니다.그리고 나서 그것들을 공백으로 개인 길이까지 채웁니다.
Git 이외에도 이러한 툴이 필요합니다.
- 그리프
- 페이스트
- 인쇄물
- sed의
- 인식하다
- tr
- wc
Linux 디스트리뷰션의 대부분이 탑재되어 있습니다.
코드 스니펫은
while IFS=+ read -r graph hash time branch message;do
# Count needed amount of white spaces and create them
whitespaces=$((9-$(sed -nl1000 'l' <<< "$graph" | grep -Eo '\\\\|\||\/|\ |\*|_' | wc -l)))
whitespaces=$(seq -s' ' $whitespaces|tr -d '[:digit:]')
# Show hashes besides the tree ...
#graph_all="$graph_all$graph$(printf '%7s' "$hash")$whitespaces \n"
# ... or in an own column
graph_all="$graph_all$graph$whitespaces\n"
hash_all="$hash_all$(printf '%7s' "$hash") \n"
# Format all other columns
time_all="$time_all$(printf '%12s' "$time") \n"
branch_all="$branch_all$(printf '%15s' "$branch")\n"
message_all="$message_all$message\n"
done < <(git log --all --graph --decorate=short --color --pretty=format:'+%C(bold 214)%<(7,trunc)%h%C(reset)+%C(dim white)%>(12,trunc)%cr%C(reset)+%C(214)%>(15,trunc)%d%C(reset)+%C(white)%s%C(reset)' && echo);
# Paste the columns together and show the table-like output
paste -d' ' <(echo -e "$time_all") <(echo -e "$branch_all") <(echo -e "$graph_all") <(echo -e "$hash_all") <(echo -e "$message_all")
우리가 사용하는 필요한 공백 공간을 계산하기 위해
sed -nl1000 'l' <<< "$graph"
트리 문자만 선택하지 않고 모든 문자(행당 1000 문자)를 가져오려면: * | / \ _ 및 공백이 있는 경우
grep -Eo '\\\\|\||\/|\ |\*|_'
마지막으로 숫자를 세고 선택한 길이 값(예에서는 9)에서 결과를 추출합니다.
우리가 사용하는 계산된 빈 공간을 생성하기 위해
seq -s' ' $whitespaces
위치 번호를 잘라냅니다.
tr -d '[:digit:]'
그런 다음 그래프 선의 끝에 추가합니다.바로 그거야!
Git에는 이미 구문을 사용하여 출력 지정자의 길이를 포맷할 수 있는 좋은 옵션이 있습니다.'%><(amount_of_characters,truncate_option)'
왼쪽 '>' 또는 오른쪽 '<'에서 공백을 추가하고 시작 'ltrunc', 중간 'mtrunc' 또는 끝 'ltrunc'에서 문자를 잘라낼 수 있습니다.
위의 printf cmd는 대응하는 Git 컬럼에 동일한 길이 값을 사용하는 것이 중요합니다.
깔끔한 테이블과 같은 출력을 니즈에 맞게 스타일링할 수 있습니다.
추가:
올바른 길이 값을 얻으려면 다음 스니펫을 사용합니다.
while read -r graph;do
chars=$(sed -nl1000 'l' <<< "$graph" | grep -Eo '\\\\|\||\/|\ |\*|_' | wc -l)
[[ $chars -gt ${max_chars:-0} ]] && max_chars=$chars
done < <(git log --all --graph --pretty=format:' ')
$max_chars로 지정됩니다.
편집 1: Git 트리에서도 밑줄 문자가 사용되고 있는 것을 확인하고, 이에 따라 위의 코드 스니펫을 편집합니다.혹시 빠진 캐릭터가 있으면 댓글로 남겨주세요.
EDIT 2: 분기와 태그 항목 주변의 괄호를 제거하려면 EDIT 3과 같이 git 명령에서 "%d" 대신 "%D"를 사용하십시오.
편집 3: 브랜치 및 태그 엔트리에 가장 적합한 색상은 자동 색상입니까?
git 명령의 이 부분을 변경합니다(컬러 214).
%C(214)%>(15,trunc)%D%C(reset)
자동차로 움직이다
%C(auto)%>(15,trunc)%D%C(reset)
편집 4: 아니면 그 부분에 맞는 컬러 믹스, 화려한 출력, 헤드 깜박임 중 어느 쪽입니까?
먼저 헤드, 브랜치명, 태그를 스타일링하기 위해서는 EDIT 3과 같이 git 명령어에 "auto" 컬러 옵션이 필요합니다.
그리고 이 세 줄을 더하면 우리가 알고 있는 색상 값을 바꿀 수 있습니다.
# branch name styling
branch=${branch//1;32m/38;5;214m}
# head styling
branch=${branch//1;36m/3;5;1;38;5;196m}
# tag styling
branch=${branch//1;33m/1;38;5;222m}
행 직전에
branch_all="$branch_all$(printf '%15s' "$branch")\n"
코드 스니펫에 있습니다.치환치에 의해 위의 색상이 생성됩니다.
예를 들어, 헤드의 치환 값은 다음과 같습니다.
3;5;1;38;5;196
여기서 3;은 이탤릭체, 5; 깜빡임, 1;38;5;색상은 이탤릭체를 나타냅니다.자세한 내용은 여기를 참조하십시오.주의: 이 동작은 마음에 드는 단말기에 따라 다르므로 사용하지 못할 수 있습니다.
단, 원하는 색상 값을 선택할 수 있습니다.
git 색상 값 및 ANSI 등가물의 개요
git color/style 옵션이 있는 목록은 여기에서 찾을 수 있습니다.
정확한 색상으로 콘솔 출력이 필요한 경우(위의 그림은 스택 오버플로에 의해 축소됨)로 출력을 생성할 수 있습니다.
for ((i=0;i<=255;i++));do
while IFS='+' read -r tree hash;do
echo -e "$(printf '%-10s' "(bold $i)") $hash $(sed -nl500 'l' <<< "$hash"|grep -Eom 1 '[0-9;]*[0-9]m'|tr -d 'm')"
done < <(git log --all --graph --decorate=short --color --pretty=format:'+%C(bold '$i')%h%C(reset)'|head -n 1)
done
Git 로그 출력의 첫 번째 커밋을 사용하는 Git 프로젝트 경로입니다.
편집 5: 멤버 "Andras Deak"가 언급했듯이 이 코드를 사용하는 방법은 몇 가지 있습니다.
1) 에일리어스로서:
에일리어스는 파라미터는 받지 않지만 함수는 사용할 수 있습니다.따라서 .timeoutrc에서 정의하기만 하면 됩니다.
function git_tably () {
unset branch_all graph_all hash_all message_all time_all max_chars
### add here the same code as under "2) as a shell-script" ###
}
git 프로젝트 경로 바로 아래 또는 git 프로젝트 경로를 첫 번째 매개 변수로 사용하여 원하는 위치에서 git_table(테이블 모양에서 파생) 함수를 호출합니다.
2) 셸 스크립트로서:
Git 프로젝트 디렉토리를 첫 번째 파라미터로 전달하거나 비어 있는 경우 일반 동작과 같이 작업 디렉토리를 가져오는 옵션과 함께 사용합니다.전체적으로는
# Edit your color/style preferences here or use empty values for git auto style
tag_style="1;38;5;222"
head_style="1;3;5;1;38;5;196"
branch_style="38;5;214"
# Determine the max character length of your git tree
while IFS=+ read -r graph;do
chars_count=$(sed -nl1000 'l' <<< "$graph" | grep -Eo '\\\\|\||\/|\ |\*|_' | wc -l)
[[ $chars_count -gt ${max_chars:-0} ]] && max_chars=$chars_count
done < <(cd "${1:-"$PWD"}" && git log --all --graph --pretty=format:' ')
# Create the columns for your preferred table-like git graph output
while IFS=+ read -r graph hash time branch message;do
# Count needed amount of white spaces and create them
whitespaces=$(($max_chars-$(sed -nl1000 'l' <<< "$graph" | grep -Eo '\\\\|\||\/|\ |\*|_' | wc -l)))
whitespaces=$(seq -s' ' $whitespaces|tr -d '[:digit:]')
# Show hashes besides the tree ...
#graph_all="$graph_all$graph$(printf '%7s' "$hash")$whitespaces \n"
# ... or in an own column
graph_all="$graph_all$graph$whitespaces\n"
hash_all="$hash_all$(printf '%7s' "$hash") \n"
# Format all other columns
time_all="$time_all$(printf '%12s' "$time") \n"
branch=${branch//1;32m/${branch_style:-1;32}m}
branch=${branch//1;36m/${head_style:-1;36}m}
branch=${branch//1;33m/${tag_style:-1;33}m}
branch_all="$branch_all$(printf '%15s' "$branch")\n"
message_all="$message_all$message\n"
done < <(cd "${1:-"$PWD"}" && git log --all --graph --decorate=short --color --pretty=format:'+%C(bold 214)%<(7,trunc)%h%C(reset)+%C(dim white)%>(12,trunc)%cr%C(reset)+%C(auto)%>(15,trunc)%D%C(reset)+%C(white)%s%C(reset)' && echo);
# Paste the columns together and show the table-like output
paste -d' ' <(echo -e "$time_all") <(echo -e "$branch_all") <(echo -e "$graph_all") <(echo -e "$hash_all") <(echo -e "$message_all")
3) git 에일리어스로서:
가장 편한 방법은 .gitconfig에 git 에일리어스를 추가하는 것입니다.
[color "decorate"]
HEAD = bold blink italic 196
branch = 214
tag = bold 222
[alias]
count-log = log --all --graph --pretty=format:' '
tably-log = log --all --graph --decorate=short --color --pretty=format:'+%C(bold 214)%<(7,trunc)%h%C(reset)+%C(dim white)%>(12,trunc)%cr%C(reset)+%C(auto)%>(15,trunc)%D%C(reset)+%C(white)%s%C(reset)'
tably = !bash -c '" \
while IFS=+ read -r graph;do \
chars_count=$(sed -nl1000 \"l\" <<< \"$graph\" | grep -Eo \"\\\\\\\\\\\\\\\\|\\||\\/|\\ |\\*|_\" | wc -l); \
[[ $chars_count -gt ${max_chars:-0} ]] && max_chars=$chars_count; \
done < <(git count-log && echo); \
while IFS=+ read -r graph hash time branch message;do \
chars=$(sed -nl1000 \"l\" <<< \"$graph\" | grep -Eo \"\\\\\\\\\\\\\\\\|\\||\\/|\\ |\\*|_\" | wc -l); \
whitespaces=$(($max_chars-$chars)); \
whitespaces=$(seq -s\" \" $whitespaces|tr -d \"[:digit:]\"); \
graph_all=\"$graph_all$graph$whitespaces\n\"; \
hash_all=\"$hash_all$(printf \"%7s\" \"$hash\") \n\"; \
time_all=\"$time_all$(printf \"%12s\" \"$time\") \n\"; \
branch_all=\"$branch_all$(printf \"%15s\" \"$branch\")\n\"; \
message_all=\"$message_all$message\n\"; \
done < <(git tably-log && echo); \
paste -d\" \" <(echo -e \"$time_all\") <(echo -e \"$branch_all\") <(echo -e \"$graph_all\") \
<(echo -e \"$hash_all\") <(echo -e \"$message_all\"); \
'"
만 하는 게 git tably
츠미야
Git은 위 그림과 같이 헤드, 태그 등을 직접 변경할 수 있을 정도로 강력합니다.
또 다른 화려한 옵션은 가장 선호하는 트리 색상을 선택하는 것입니다.
[log]
graphColors = bold 160, blink 231 bold 239, bold 166, bold black 214, bold green, bold 24, cyan
미친 것처럼 보이지만 항상 테이블과 같은 git 로그 출력을 제공합니다.
너무 많이 깜빡여요!가능한 것을 증명하기 위해서입니다.지정된 색상이 너무 적으면 색상이 반복됩니다.
클릭 한 번으로 완전한 .gitconfig 참조를 얻을 수 있습니다.
편집 6: 당신의 긍정적인 투표 덕분에 나는 그 단편들을 개선했다. 이제 거의 모든 git log 명령어로 데이터를 전송할 수 있으며 코드를 더 이상 조정할 필요가 없습니다. 해봐!
어떻게 작동합니까?
- .gitconfig에서 Git 로그 명령어를 항상처럼 정의합니다(아래 형식).
- git 그래프가 표시되는 양의 트리 열 번호를 정의합니다(옵션).
그럼 전화나 해
git tably YourLogAlias
모든 git 프로젝트 경로 또는
git tably YourLogAlias TreeColNumber
여기서 TreeColNumber는 항상 정의된 값을 위에서 덮어씁니다.
git tably YourLogAlias | less -r
파이프에 의한 출력의 감소가 큰 이력에 도움이 됩니다.
Git 로그 에일리어스는 다음 형식 규칙을 따라야 합니다.
각 열은 사용자가 선택해야 하는 열 구분 기호로 표시되어야 하며, 고유하지 않으면 문제가 발생할 수 있습니다.
ㅇㅇㅇ.
^
...format:'^%h^%cr^%s'
및 이 생성됩니다.내의 에 log를 사용해야 .
%><(<N>[,ltrunc|mtrunc|trunc])
중 "" " " " " " 입니다(구문에 대한 설명은http://https://git-scm.com/docs/pretty-formats), 를 참조해 주세요.
단, newline의 마지막 커밋 플레이스홀더는 newline 없이 사용할 수 있습니다.
ㅇㅇㅇ.
...format:'^%<(7,trunc)%h^%<(12,trunc)%cr^%s'
에 여분의
(committer:
,<
★★★★★★★★★★★★★★★★★」>)
...%C(dim white)(committer: %cn% <%ce>)%C(reset)...
테이블과 같은 출력을 얻으려면 커밋 플레이스 홀더 바로 앞과 뒤에 작성해야 합니다.
ㅇㅇㅇ.
...%C(dim white)%<(25,trunc)(committer: %cn%<(25,trunc) <%ce>)%C(reset)...
을
%C(white)...%C(reset)
「」가 합니다.--color
ㅇㅇㅇ.
...--color...format:'^%C(white)%<(7,trunc)%h%C(reset)...
를
--stat
등,행 「」, 「」를 합니다.%n
ㅇㅇㅇ.
...--stat...format:'...%n'...
는 줄 빈 줄만 한할 수 .
format:'...%n'
줄바꿈의 경우
...%n%CommitPlaceholder...
는 각 의 n번째 이 모두 에만 n할 수 .열 은 "알겠습니다"여야 .
YourLogAlias-col
일반 git 로그 출력에 비해 느리지만 좋습니다.
이제 .gitconfig에 추가할 개량된 스니펫입니다.
[color "decorate"]
HEAD = bold blink italic 196
branch = 214
tag = bold 222
[alias]
# Delimiter used in every mylog alias as column seperator
delim = ^
# Short overview about the last hashes without graph
mylog = log --all --decorate=short --color --pretty=format:'^%C(dim white)%>(12,trunc)%cr%C(reset)^%C(bold 214)%<(7,trunc)%h%C(reset)' -5
# Log with hashes besides graph tree
mylog2 = log --all --graph --decorate=short --color --pretty=format:'%C(bold 214)%<(7,trunc)%h%C(reset)^%C(dim white)%>(12,trunc)%cr%C(reset)^%C(auto)%>(15,trunc)%D%C(reset)^%C(white)%<(80,trunc)%s%C(reset)'
mylog2-col= 3
# Log with hashes in an own column and more time data
mylog3 = log --all --graph --decorate=short --color --pretty=format:'^%C(dim white)%>(12,trunc)%cr%C(reset)^%C(cyan)%<(10,trunc)%cs%C(reset)^%C(bold 214)%<(7,trunc)%h%C(reset)^%C(auto)%<(15,trunc)%D%C(reset)^%C(white)%s%C(reset)'
mylog3-col= 4
tably = !bash -c '" \
\
\
declare -A col_length; \
apost=$(echo -e \"\\u0027\"); \
delim=$(git config alias.delim); \
git_log_cmd=$(git config alias.$1); \
git_tre_col=${2:-$(git config alias.$1-col)}; \
[[ -z "$git_tre_col" ]] && git_tre_col=1; \
[[ -z "$git_log_cmd" ]] && { git $1;exit; }; \
\
\
i=0; \
n=0; \
while IFS= read -r line;do \
((n++)); \
while read -d\"$delim\" -r col_info;do \
((i++)); \
[[ -z \"$col_info\" ]] && col_length[\"$n:$i\"]=${col_length[\"${last[$i]:-1}:$i\"]} && ((i--)) && continue; \
[[ $i -gt ${i_max:-0} ]] && i_max=$i; \
col_length[\"$n:$i\"]=$(grep -Eo \"\\([0-9]*,[lm]*trunc\\)\" <<< \"$col_info\" | grep -Eo \"[0-9]*\" | head -n 1); \
[[ -n \"${col_length[\"$n:$i\"]}\" ]] && last[$i]=$n; \
chars_extra=$(grep -Eo \"trunc\\).*\" <<< \"$col_info\"); \
chars_extra=${chars_extra#trunc)}; \
chars_begin=${chars_extra%%\\%*}; \
chars_extra=${chars_extra%$apost*}; \
chars_extra=${chars_extra#*\\%}; \
case \" ad aD ae aE ai aI al aL an aN ar as at b B cd cD ce cE ci cI cl cL cn cN cr \
cs ct d D e f G? gd gD ge gE GF GG GK gn gN GP gs GS GT h H N p P s S t T \" in \
*\" ${chars_extra:0:2} \"*) \
chars_extra=${chars_extra:2}; \
chars_after=${chars_extra%%\\%*}; \
;; \
*\" ${chars_extra:0:1} \"*) \
chars_extra=${chars_extra:1}; \
chars_after=${chars_extra%%\\%*}; \
;; \
*) \
echo \"No Placeholder found. Probably no tablelike output.\"; \
continue; \
;; \
esac; \
if [[ -n \"$chars_begin$chars_after\" ]];then \
len_extra=$(echo \"$chars_begin$chars_after\" | wc -m); \
col_length["$n:$i"]=$((${col_length["$n:$i"]}+$len_extra-1)); \
fi; \
done <<< \"${line#*=format:}$delim\"; \
i=1; \
done <<< \"$(echo -e \"${git_log_cmd//\\%n/\\\\n}\")\"; \
\
\
git_log_fst_part=\"${git_log_cmd%%\"$apost\"*}\"; \
git_log_lst_part=\"${git_log_cmd##*\"$apost\"}\"; \
git_log_tre_part=\"${git_log_cmd%%\"$delim\"*}\"; \
git_log_tre_part=\"${git_log_tre_part##*\"$apost\"}\"; \
git_log_cmd_count=\"$git_log_fst_part$apost $git_log_tre_part$apost$git_log_lst_part\"; \
col_length[\"1:1\"]=$(eval git \"${git_log_cmd_count// --color}\" | wc -L); \
\
\
i=0; \
while IFS=\"$delim\" read -r graph rest;do \
((i++)); \
graph_line[$i]=\"$graph\"; \
done < <(eval git \"${git_log_cmd/ --color}\" && echo); \
\
\
i=0; \
l=0; \
while IFS= read -r line;do \
c=0; \
((i++)); \
((l++)); \
[[ $l -gt $n ]] && l=1; \
while IFS= read -d\"$delim\" -r col_content;do \
((c++)); \
[[ $c -le $git_tre_col ]] && c_corr=-1 || c_corr=0; \
if [[ $c -eq 1 ]];then \
[[ \"${col_content/\\*}\" = \"$col_content\" ]] && [[ $l -eq 1 ]] && l=$n; \
count=$(wc -L <<< \"${graph_line[$i]}\"); \
whitespaces=$(seq -s\" \" $((${col_length[\"1:1\"]}-$count))|tr -d \"[:digit:]\"); \
col_content[$git_tre_col]=\"${col_content}$whitespaces\"; \
else \
col_content[$c+$c_corr]=\"$(printf \"%-${col_length[\"$l:$c\"]}s\" \"${col_content:-\"\"}\")\"; \
fi; \
done <<< \"$line$delim\"; \
for ((k=$c+1;k<=$i_max;k++));do \
[[ $k -le $git_tre_col ]] && c_corr=-1 || c_corr=0; \
col_content[$k+$c_corr]=\"$(printf \"%-${col_length[\"$l:$k\"]:-${col_length[\"${last[$k]:-1}:$k\"]:-0}}s\" \"\")\"; \
done; \
unset col_content[0]; \
echo -e \"${col_content[*]}\"; \
unset col_content[*]; \
done < <(eval git \"$git_log_cmd\" && echo); \
"' "git-tably"
잘 들어맞는 곳에
- 첫 번째 단락은 딜리미터, YourLogAlias 및 YourLogAlias-col을 셸 변수에 로드합니다.
- 두 번째는 각 열의 길이를 읽어낸다
- 세 번째는 나무의 최대 길이를 센다.
- 넷째는 나무를 배열에 싣는다.
- 다섯 번째는 표와 같은 출력을 정리하고 인쇄한다
결과:
또는 새로운 Tree Col Number를 즉시 사용할 수 있습니다.
다시: 깔끔한 테이블과 같은 출력을 니즈에 맞게 스타일링할 수 있습니다.
원하는 형식의 Git 로그 에일리어스를 댓글로 공유할 수도 있습니다.위 텍스트에 최고 등급을 기재하고 이미지 추가도 수시로 하겠습니다.
관련 질문에 대한 답변에서 찾은 Graphviz 스크립트를 기반으로 Git 저장소의 요약 뷰를 만드는 Ruby 스크립트를 해킹했습니다.이것은 모든 선형 이력을 지우고 "흥미로운" 커밋(즉, 여러 부모, 여러 자녀가 있거나 분기 또는 태그로 가리킨 커밋)을 보여줍니다.다음은 jQuery에 대해 생성되는 그래프의 일부입니다.
git-big-picture와 BranchMaster는 태그, 분기, 병합 등의 연관성만을 표시함으로써 그래프의 높은 수준의 구조만을 보여주려고 하는 유사한 도구입니다.
이 질문에는 몇 가지 선택지가 있습니다.
세 명령어를 git tree
,git stree
★★★★★★★★★★★★★★★★★」git vtree
그 순서대로 살펴보도록 하겠습니다.
[alias]
tree = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset) %C(auto)%d%C(reset)\n %C(black)[%cr]%C(reset) %x09%C(black)%an: %s %C(reset)'
★★★★★★★★★★★★★★★★ git stree
★★★★★★★★★★★★★★★★★」git vtree
배쉬하다
[alias]
logx = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset)+%C(dim black)(%cr)%C(reset)+%C(auto)%d%C(reset)++\n+++ %C(bold black)%an%C(reset)%C(black): %s%C(reset)'
stree = !bash -c '" \
while IFS=+ read -r hash time branch message; do \
timelength=$(echo \"$time\" | sed -r \"s:[^ ][[]([0-9]{1,2}(;[0-9]{1,2})?)?m::g\"); \
timelength=$(echo \"16+${#time}-${#timelength}\" | bc); \
printf \"%${timelength}s %s %s %s\n\" \"$time\" \"$hash\" \"$branch\" \"\"; \
done < <(git logx && echo);"'
[alias]
logx = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset)+%C(dim black)(%cr)%C(reset)+%C(auto)%d%C(reset)++\n+++ %C(bold black)%an%C(reset)%C(black): %s%C(reset)'
vtree = !bash -c '" \
while IFS=+ read -r hash time branch message; do \
timelength=$(echo \"$time\" | sed -r \"s:[^ ][[]([0-9]{1,2}(;[0-9]{1,2})?)?m::g\"); \
timelength=$(echo \"16+${#time}-${#timelength}\" | bc); \
printf \"%${timelength}s %s %s %s\n\" \"$time\" \"$hash\" \"$branch\" \"$message\"; \
done < <(git logx && echo);"'
이것은 Git 버전 1.9a에서 작동합니다.색상 값 'auto'가 이번 출시에서 첫 선을 보이는 것 같다.지점 이름이 바뀌기 때문에 좋은 추가입니다.이를 통해 예를 들어 로컬브런치와 리모트브런치를 쉽게 구별할 수 있습니다.
자세한 텍스트 출력을 보려면 다음을 참조하십시오.
git log --graph --date-order -C -M --pretty=format:"<%h> %ad [%an] %Cgreen%d%Creset %s" --all --date=short
$HOME/.gitconfig 파일에 에일리어스를 추가할 수 있습니다.
[alias]
graph = log --graph --date-order -C -M --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=short
어떻게 생겼느냐에 따라 다르죠.다음과 같은 사진을 만드는 gitx를 사용합니다.
가 합니다.git log --graph
vs. gitk는 24-way 문어 머지(일반적으로 http://clojure-log.n01se.net/date/2008-12-24.html):
Visual Studio Code는 놀라운 확장을 가지고 있습니다 - Git Graph:
이 문제에 대한 나의 견해는 이렇다.
스크린샷:
사용방법:
git hist
합니다. - 현재 지점의 이력을 표시합니다.
git hist --all
- 포함 - 모든 브랜치(리모트 포함)를 표시합니다
git hist master devel
- 두 개 이상의 분기의 관계 표시
git hist --branches
- 로컬브런치 표시 -
--topo-order
날짜별이 아닌 위상적으로 커밋 정렬(이 별칭에서는 기본값)
이점:
- 밋밋해
--decorate
있습니다 - 커밋 이메일 추가
- 커밋 상대일과 절대일을 추가합니다.
- 날짜별로 커밋 정렬
셋업:
git config --global alias.hist "log --graph --date-order --date=short \
--pretty=format:'%C(auto)%h%d %C(reset)%s %C(bold blue)%ce %C(reset)%C(green)%cr (%cd)'"
gitg: gtk 기반의 저장소 뷰어.그것은 새롭지만 흥미롭고 유용하다.
지금 쓰고 있어요.
가끔 gitg를 사용하지만 항상 명령줄로 돌아갑니다.
[alias]
# Quick look at all repositories
loggsa = log --color --date-order --graph --oneline --decorate --simplify-by-decoration --all
# Quick look at active branch (or refs pointed)
loggs = log --color --date-order --graph --oneline --decorate --simplify-by-decoration
# Extend look at all repo
logga = log --color --date-order --graph --oneline --decorate --all
# Extend look at active branch
logg = log --color --date-order --graph --oneline --decorate
# Look with the date
logda = log --color --date-order --date=local --graph --format=\"%C(auto)%h%Creset %C(blue bold)%ad%Creset %C(auto)%d%Creset %s\" --all
logd = log --color --date-order --date=local --graph --format=\"%C(auto)%h%Creset %C(blue bold)%ad%Creset %C(auto)%d%Creset %s\"
# Look with the relative date
logdra = log --color --date-order --graph --format=\"%C(auto)%h%Creset %C(blue bold)%ar%Creset %C(auto)%d%Creset %s\" --all
logdr = log --color --date-order --graph --format=\"%C(auto)%h%Creset %C(blue bold)%ar%Creset %C(auto)%d%Creset %s\"
loga = log --graph --color --decorate --all
# For repositories without subject body commits (Vim repository, git-svn clones)
logt = log --graph --color --format=\"%C(auto)%h %d %<|(100,trunc) %s\"
logta = log --graph --color --format=\"%C(auto)%h %d %<|(100,trunc) %s\" --all
logtsa = log --graph --color --format=\"%C(auto)%h %d %<|(100,trunc) %s\" --all --simplify-by-decoration
보시는 바와 같이 이는 거의 키 스트로크를 사용하여 에일리어스를 저장합니다.
- --color: 클리어 룩
- --graph: 부모 시각화
- --date-order: repo에서 가장 이해하기 쉬운 보기
- --param: 누가 누구입니까?
- --온라인:커밋에 대해 알아야 할 모든 것은
- --장식별 : 첫눈에 베이직 (태그, 관련 머지, 브랜치만)
- --all: 이 옵션을 사용하는 경우와 사용하지 않는 경우의 모든 에일리어스와 함께 키 스트로크를 저장합니다.
- --date=module(%ar):레포의 액티비티를 파악한다(종종 브랜치는 마스터에 가까운 몇 개의 커밋이지만, 몇 달 전에 마스터로부터 커밋이 될 수 있다.
Git 의 최신 버전(1.8.5 이상)을 참조해 주세요.장식 플레이스 홀더 %d 의 %C(auto)를 이용할 수 있습니다.
여기서 필요한 것은 gitrevisions를 잘 이해하고 필요한 것을 필터링하는 것입니다(마스터 등).개발, 장소--simplify-merges
을 사용하다
power behind 명령행은 필요에 따라 신속하게 구성할 수 있습니다(저장소는 고유한 키 로그 구성이 아니므로 --numstat, --raw 또는 --name-status를 추가해야 할 수 있습니다).서 ★★★★git log
에일리어스는 빠르고 강력하며 (시간이 지남에 따라) 얻을 수 있는 가장 예쁜 그래프입니다.게다가 디폴트에서는, 출력은 호출기로 표시되기 때문에, 언제라도 결과를 재빠르게 검색할 수 있습니다.납득이 안 가?gitgraph와 같은 프로젝트로 언제든지 결과를 해석할 수 있습니다.
tig
https://github.com/jonas/tig,은 Git을 위한 훨씬 더 나은 명령줄 도구입니다.
Homebrew를 사용하여 MacOS에 tig를 설치할 수 있습니다.
$ brew install tig
$ tig
Slip의 멋진 답변을 약간 수정하면 그의 가명을 사용하여 하나의 분기만 기록할 수 있습니다.
[alias]
lgBranch1 = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
lgBranch2 = log --graph --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(bold white)— %an%C(reset)' --abbrev-commit
lg = !"git lg1"
--all
할 수
git lgBranch1 <branch name>
또는 심지어
git lgBranch1 --all
게 요.git log
~/.gitconfig
「 」 「 」 력시 :
[alias]
l = log --all --graph --pretty=format:'%C(auto)%h%C(auto)%d %s %C(dim white)(%aN, %ar)'
하면, 「 」가 .git l
하다
Git 2.12+에서는 구성 옵션을 사용하여 그래프의 선 색상을 맞춤화할 수도 있습니다.
로그 형식에 대해서는 와 비슷하며, 작성자 이름(존중)이 추가됩니다..mailmap
) 및 관련 작성자 날짜.주의:%C(auto)
Git > = 1.8.3에서는 Git에 커밋 해시 등에 기본 색상을 사용하도록 지시하는 구문이 지원됩니다.
★★를 해 보세요.gitk
★★★★★★★★★★★★★★★★★」gitk --all
img, img, img, img, img, img, img, img, img, img.
셸의 보다 가지 같은 컬러 버전입니다.
다른 답변에서는 그래프 트리가 외부 도구에 의해 아름답게 색칠되어 있으며 일부는 색칠된 선 정보로 색칠되어 있습니다.이것은 셸에 대한 나의 접근법입니다.이것은 테이블과 같은 출력에 대한 첫 번째 답변과 조합한 것입니다(https://stackoverflow.com/a/61487052)).
특징:
- 모든 트리 색상을 정의할 수 있습니다.
- 해당하는 분기 색상의 모든 열을 염색할 수 있습니다.
- 트리 기둥을 다른 위치에 배치할 수 있습니다.
- 여러 가지로 할 수 있어요.
git log
- 각 별칭에 대한 트리 열 번호를 정의할 수 있습니다.
- 로 연결하면 .
less -r
역사를
사용방법:
「」의 정의」git log
예를 들어 Slip D., albfan, kaoru 등의 몇 가지 답변과 같이 아래에 기재된 포맷 지침을 사용하여 코드 스니펫과 함께 .gitconfig 파일에 붙여 넣습니다.프로젝트 경로에서 호출할 수 있습니다.일반적으로
git colored YourLogAlias
또또또또와 함께
git colored YourLogAlias TreeColumnNumber
나무 기둥을 파리 위에 올려놓습니다.
포맷 순서:
의 ★★★★★★★★★★★★★★★★★.git log
는 다음과 규칙을 합니다.
- 커밋 마다 하나의 「」는 「」입니다.
^
...format:'%h%cr%s'
-->...format:'^%h^%cr^%s'
- 를 한 가지 합니다.
...format:'^%h^%cr^%s'
-->...format:'^%h^%cr^%C(white)%s%C(reset)'
( 색상의 및 (해시 및 시간) - 어떤 '너비'를 ''
%><(<N>[,ltrunc|mtrunc|trunc])
옵션 중 하나를 할 수 단, 이 플레이스 홀더를 사용하지 않고 사용할 수 있습니다.
...format:'^%h^%cr^%C(white)%s%C(reset)'
-->...format:'^%<(7,trunc)%h^%<(12,trunc)%cr^%C(white)%<(50,trunc)%s%C(reset)'
- 한 경우 플레이스 홀더 "Decoration").
Commit:
...^%C(white)%<(50,trunc)%s%C(reset)...
-->...^%C(white)%<(50,trunc)Commit:%s%C(reset)...
- 을 사용하는
%n
.
...^%C(white)%<(50,trunc)Commit:%s%C(reset)'
-->...%n^%C(white)%<(50,trunc)Commit:%s%C(reset)%n'
- 를 들어 '컬럼 를
%C(white)
에서는 '어울리지 않다'를 넣어야 .--color
표시
...format:'^%<(7,trunc)%h...
-->...--color...format:'^%<(7,trunc)%h...
- 를
--stat
등,행 「」, 「」를 합니다.%n
...--stat...format:'...'
-->...--stat...format:'...%n'
기타:
★★★★★★★★★★★★★★★★★★에
git log
이 아닌 줄바꿈을...%n%CommitPlaceholder...
각이 존재하고 한 widthGit을 에만 n할 수YourLogAlias-col
.gitconfig 파일에서 TreeColumnNumber를 정의하는 경우 이름을 지정해야 합니다.YourLogAlias
의 통통 the the to와
git log
느리지만 입니다.
예:
코드 스니펫:
.gitconfig 파일에 다음 행을 추가합니다.
[alias]
# Define your unique column separator
delim = ^
# Define your 'git log' aliases and optional tree column numbers
lgc1 = log --all --graph --color --pretty=format:'^%<(7,trunc)%h^%C(white)%<(15,trunc)- %ar -%C(reset)^%<(35,trunc)%s^%C(white)%an%C(reset)'
lgc2 = log --all --graph --color --pretty=format:'%D^%<(7,trunc)%h^%<(35,trunc)%s^%C(white)%<(20,trunc)%an%C(reset)^%C(white) (%ar)%C(reset)'
lgc2-col = 2
lgc3 = log --all --graph --color --pretty=format:'%<(7,trunc)%h%d^%<(11,trunc)%cs%C(reset)^%s%n^%C(white)%<(11,trunc)%cr%C(reset)^%C(white)%<(25,trunc)From %an%C(reset)^%C(white)%ae%C(reset)%n'
lgc3-col = 2
lgc4 = log --all --graph --color --pretty=format:'%h^%C(white)%<(25,trunc)%an%C(reset)^%C(white)%<(31,trunc)%aD%C(reset)^%s%n^%C(dim white)%<(25,trunc)%ae%C(reset)^%>(31,trunc)%D%C(reset)%n'
lgc4-col = 3
# Define your whitespace seperated tree color list
color-list = "1;38;5;222 1;38;5;69 1;38;5;250 1;38;5;70 1;31 1;38;5;93 1;33 2;38;5;11 1;38;5;48 1;35 1;32 1;38;5;111 1;38;5;160 1;38;5;130 1;36 38;5;21"
Bash 스니펫을 .gitconfig 파일에도 추가합니다.
# This is the Bash snippet which does all the magic
colored = !bash -c '" \
\
\
declare -A col_length col_colored; \
apost=$(echo -e \"\\u0027\"); \
delim=$(git config alias.delim); \
git_log_cmd=$(git config alias.$1); \
graph_col=${2:-$(git config alias.$1-col)}; \
color_list=( $(git config alias.color-list) ); \
[[ -z \"$graph_col\" ]] && graph_col=1; \
[[ -z \"$git_log_cmd\" ]] && { git $1;exit; }; \
\
\
i=0; \
n=0; \
while IFS= read -r line; do \
((n++)); \
while read -d\"$delim\" -r col_info;do \
((i++)); \
[[ -z \"$col_info\" ]] && col_length[\"$n:$i\"]=${col_length[\"${last[$i]:-1}:$i\"]} && ((i--)) && continue; \
[[ $i -gt ${i_max:-0} ]] && i_max=$i; \
[[ \"${col_info:1:1}\" = \"C\" ]] && col_colored[\"$n:$i\"]=1; \
col_length[\"$n:$i\"]=$(grep -Eo \"\\([0-9]*,[lm]*trunc\\)\" <<< \"$col_info\" | grep -Eo \"[0-9]*\" | head -n 1); \
[[ -n \"${col_length[\"$n:$i\"]}\" ]] && last[$i]=$n; \
chars_extra=$(grep -Eo \"\\trunc\\).*\" <<< \"$col_info\"); \
chars_extra=${chars_extra#trunc)}; \
chars_begin=${chars_extra%%\\%*}; \
chars_extra=${chars_extra%$apost*}; \
chars_extra=${chars_extra#*\\%}; \
case \" ad aD ae aE ai aI al aL an aN ar as at b B cd cD ce cE ci cI cl cL cn cN cr \
cs ct d D e f G? gd gD ge gE GF GG GK gn gN GP gs GS GT h H N p P s S t T \" in \
*\" ${chars_extra:0:2} \"*) \
chars_extra=${chars_extra:2}; \
chars_after=${chars_extra%%\\%*}; \
;; \
*\" ${chars_extra:0:1} \"*) \
chars_extra=${chars_extra:1}; \
chars_after=${chars_extra%%\\%*}; \
;; \
*) \
echo \"No Placeholder found. Probably no table-like output.\"; \
continue; \
;; \
esac; \
if [[ -n \"$chars_begin$chars_after\" ]];then \
len_extra=$(echo \"$chars_begin$chars_after\" | wc -m); \
col_length[\"$n:$i\"]=$((${col_length[\"$n:$i\"]}+$len_extra-1)); \
fi; \
done <<< \"${line#*=format:}$delim\"; \
i=1; \
done <<< \"$(echo -e \"${git_log_cmd//\\%n/\\\\n}\")\"; \
\
\
git_log_fst_part=\"${git_log_cmd%%\"$apost\"*}\"; \
git_log_lst_part=\"${git_log_cmd##*\"$apost\"}\"; \
git_log_tre_part=\"${git_log_cmd%%\"$delim\"*}\"; \
git_log_tre_part=\"${git_log_tre_part##*\"$apost\"}\"; \
git_log_cmd_count=\"$git_log_fst_part$apost $git_log_tre_part$apost$git_log_lst_part\"; \
col_length[\"1:1\"]=$(eval git \"${git_log_cmd_count// --color}\" | wc -L); \
\
\
i=0; \
while IFS=\"$delim\" read -r graph rest;do \
((i++)); \
graph_line[$i]=\"$graph\"; \
done < <(eval git \"${git_log_cmd/ --color}\" && echo); \
\
\
i=0; \
l=0; \
msg_err=; \
color_list_ind=-1; \
color_list_num=${#color_list[*]}; \
color_repeat_ind=1; \
if [[ $color_list_num -eq 0 ]];then \
echo \"No tree colors specified via color-list under section [alias] in your .gitconfig\"; \
echo \"Therefore collecting available Git colors, which may take a while ...\"; \
while read -d\"[\" -r char;do \
color=$(sed -nl99 \"l\" <<< \"$char\"); \
case \"$color\" in \
*\"m\"*) \
color=${color%%m*}; \
;; \
*) \
continue; \
;; \
esac; \
case \" $color_list \" in \
*\" $color \"*) \
continue; \
;; \
*) \
color_list=\"$color_list$color \"; \
;; \
esac; \
done <<< \"$(git log --all --color --graph --pretty=format:)\"; \
echo -e \"Temporary used color-list = \\\"${color_list% }\\\"\\n\"; \
color_list=( ${color_list% } ); \
color_list_num=${#color_list[*]}; \
fi; \
while IFS= read -r line;do \
((i++)); \
j=-1; \
case_off=; \
graph_colored=; \
graph_line_last=\"${graph_line[$i-1]}\"; \
graph_line=\"${graph_line[$i]}\"; \
graph_line_next=\"${graph_line[$i+1]}\"; \
while IFS= read -r char;do \
((j++)); \
case \"$case_off$char\" in \
[^\\ \\_\\*\\/\\|\\\\]|\"case_off\"*) \
graph_colored=\"${graph_colored}\\033[${point_color}m$char\\033[0m\"; \
case_off=\"case_off\"; \
;; \
\" \") \
graph_colored=\"${graph_colored}$char\"; \
case \"$char_last\" in \
\" \") \
unset color_ind[$j]; \
;; \
esac; \
;; \
\"*\") \
case \"${graph_line_last:$j:1}\" in \
\"*\") \
:; \
;; \
\"|\") \
case \"${graph_line_last:$(($j-1)):1}\" in \
\"\\\\\") \
color_ind[$j]=${color_ind_last[$j-1]:-${color_ind[$j-1]}}; \
;; \
*) \
:; \
;; \
esac; \
;; \
\" \") \
case \"${graph_line_last:$(($j-1)):1}\" in \
\"\\\\\") \
color_ind[$j]=${color_ind_last[$j-1]:-${color_ind[$j-1]}}; \
;; \
\"/\") \
case \"${graph_line_last:$(($j+1)):1}\" in \
\"/\") \
color_ind[$j]=${color_ind[$j+1]}; \
;; \
\" \") \
new_col_ind=${#color[*]}; \
while true;do \
((color_list_ind++)); \
[[ $color_list_ind -ge $color_list_num ]] && color_list_ind=$color_repeat_ind; \
[[ $color_list_ind -ge $color_list_num ]] && break; \
new_color=${color_list[$color_list_ind]}; \
case \"$new_color\" in \
\"\"|[\\ ]*) \
continue; \
;; \
\"${color[${color_ind[$j-1]}]}\") \
[[ $(($color_list_num-$color_repeat_ind)) -gt 1 ]] && continue; \
;;& \
*) \
color[$new_col_ind]=$new_color; \
color_ind[$j]=$new_col_ind; \
last_new_colored_line=$i; \
break; \
;; \
esac 2>/dev/null; \
done; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
\" \") \
case \"${graph_line_last:$(($j+1)):1}\" in \
\"/\") \
color_ind[$j]=${color_ind[$j+1]}; \
;; \
*) \
new_col_ind=${#color[*]}; \
while true;do \
((color_list_ind++)); \
[[ $color_list_ind -ge $color_list_num ]] && color_list_ind=$color_repeat_ind; \
[[ $color_list_ind -ge $color_list_num ]] && break; \
new_color=${color_list[$color_list_ind]}; \
case \"$new_color\" in \
\"\"|[\\ ]*) \
continue; \
;; \
\"${color[${color_ind[$j-1]}]}\") \
[[ $(($color_list_num-$color_repeat_ind)) -gt 1 ]] && continue; \
;;& \
*) \
color[$new_col_ind]=$new_color; \
color_ind[$j]=$new_col_ind; \
last_new_colored_line=$i; \
break; \
;; \
esac 2>/dev/null; \
done; \
;; \
esac; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
\"\"|[^\\ \\_\\*\\/\\|\\\\]) \
new_col_ind=${#color[*]}; \
while true;do \
((color_list_ind++)); \
[[ $color_list_ind -ge $color_list_num ]] && color_list_ind=$color_repeat_ind; \
[[ $color_list_ind -ge $color_list_num ]] && break; \
new_color=${color_list[$color_list_ind]}; \
case \"$new_color\" in \
\"\"|[\\ ]*) \
continue; \
;; \
\"${color[${color_ind[$j-1]}]}\") \
[[ $(($color_list_num-$color_repeat_ind)) -gt 1 ]] && continue; \
;;& \
*) \
color[$new_col_ind]=$new_color; \
color_ind[$j]=$new_col_ind; \
last_new_colored_line=$i; \
break; \
;; \
esac 2>/dev/null; \
done; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
graph_colored=\"${graph_colored}\\033[${color[${color_ind[$j]}]}m$char\\033[0m\"; \
point_color=${color[${color_ind[$j]}]}; \
;; \
\"|\") \
case \"${graph_line_last:$j:1}\" in \
\" \") \
case \"${graph_line_last:$(($j-1)):1}\" in \
\"/\") \
color_ind[$j]=${color_ind[$j+1]}; \
;; \
\"\\\\\") \
color_ind[$j]=${color_ind_last[$j-1]:-${color_ind[$j-1]}}; \
;; \
*) \
case \"${graph_line_last:$(($j+1)):1}\" in \
\"/\") \
color_ind[$j]=${color_ind[$j+1]}; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
esac; \
;; \
\"|\") \
case \"${graph_line_last:$(($j-1)):1}\" in \
\"\\\\\") \
case \"${graph_line:$(($j+1)):1}\" in \
\"\\\\\") \
:; \
;; \
\" \") \
color_ind[$j]=${color_ind_last[$j-1]}; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
*) \
:; \
;; \
esac; \
;; \
\"*\") \
case \"${graph_line:$(($j-1)):1}\" in \
\"/\") \
if [[ $last_new_colored_line -eq $(($i-1)) ]];then \
new_col_ind=${#color[*]}; \
while true;do \
((color_list_ind++)); \
[[ $color_list_ind -ge $color_list_num ]] && color_list_ind=$color_repeat_ind; \
[[ $color_list_ind -ge $color_list_num ]] && break; \
new_color=${color_list[$color_list_ind]}; \
case \"$new_color\" in \
\"\"|[\\ ]*) \
continue; \
;; \
\"${color[${color_ind[$j-1]}]}\") \
[[ $(($color_list_num-$color_repeat_ind)) -gt 1 ]] && continue; \
;;& \
*) \
color[$new_col_ind]=$new_color; \
color_ind[$j]=$new_col_ind; \
break; \
;; \
esac 2>/dev/null; \
done; \
else \
color_ind[$j]=${color_ind_last[$j]}; \
fi; \
;; \
*) \
:; \
;; \
esac; \
;; \
\"/\") \
color_ind[$j]=${color_ind[$j]}; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
graph_colored=\"${graph_colored}\\033[${color[${color_ind[$j]}]}m$char\\033[0m\"; \
;; \
\"/\") \
case \"${graph_line_last:$(($j)):1}\" in \
\"|\") \
case \"${graph_line_last:$(($j+1)):1}\" in \
\"/\") \
case \"${graph_line_next:$j:1}\" in \
\"|\") \
color_ind[$j]=${color_ind[$j+1]}; \
;; \
\" \") \
color_ind[$j]=${color_ind[$j]}; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
*) \
color_ind[$j]=${color_ind[$j]}; \
;; \
esac; \
;; \
*) \
case \"${graph_line_last:$(($j+2)):1}\" in \
\"/\"|\"_\") \
color_ind[$j]=${color_ind[$j+2]}; \
;; \
*) \
case \"${graph_line_last:$(($j+1)):1}\" in \
\"/\"|\"_\"|\"|\") \
color_ind[$j]=${color_ind[$j+1]}; \
;; \
\"*\") \
case \"${graph_line:$(($j+1)):1}\" in \
\"|\") \
if [[ $last_new_colored_line -eq $(($i-1)) ]];then \
color_ind[$j]=${color_ind_last[$j+1]}; \
else \
new_col_ind=${#color[*]}; \
while true;do \
((color_list_ind++)); \
[[ $color_list_ind -ge $color_list_num ]] && color_list_ind=$color_repeat_ind; \
[[ $color_list_ind -ge $color_list_num ]] && break; \
new_color=${color_list[$color_list_ind]}; \
case \"$new_color\" in \
\"\"|[\\ ]*) \
continue; \
;; \
\"${color[${color_ind[$j-1]}]}\") \
[[ $(($color_list_num-$color_repeat_ind)) -gt 1 ]] && continue; \
;;& \
*) \
color[$new_col_ind]=$new_color; \
color_ind[$j]=$new_col_ind; \
break; \
;; \
esac 2>/dev/null; \
done; \
fi; \
;; \
*) \
color_ind[$j]=${color_ind_last[$j+1]}; \
;; \
esac; \
;; \
*) \
case \"${graph_line_last:$j:1}\" in \
\"\\\\\") \
:; \
;; \
\" \") \
case \"${graph_line_last:$(($j+1)):1}\" in \
\"*\") \
color_ind[$j]=${color_ind[$j+1]}; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
esac; \
;; \
esac; \
;; \
esac; \
graph_colored=\"${graph_colored}\\033[${color[${color_ind[$j]}]}m$char\\033[0m\"; \
;; \
\"\\\\\") \
case \"${graph_line_last:$(($j-1)):1}\" in \
\"|\"|\"\\\\\") \
color_ind[$j]=${color_ind_last[$j-1]:-${color_ind[$j-1]}}; \
;; \
\"*\") \
new_col_ind=${#color[*]}; \
while true;do \
((color_list_ind++)); \
[[ $color_list_ind -ge $color_list_num ]] && color_list_ind=$color_repeat_ind; \
[[ $color_list_ind -ge $color_list_num ]] && break; \
new_color=${color_list[$color_list_ind]}; \
case \"$new_color\" in \
\"\"|[\\ ]*) \
continue; \
;; \
\"${color[${color_ind[$j-1]}]}\") \
[[ $(($color_list_num-$color_repeat_ind)) -gt 1 ]] && continue; \
;;& \
*) \
color[$new_col_ind]=$new_color; \
color_ind[$j]=$new_col_ind; \
break; \
;; \
esac 2>/dev/null; \
done; \
;; \
\" \") \
case \"${graph_line_last:$(($j-2)):1}\" in \
\"\\\\\"|\"_\") \
color_ind[$j]=${color_ind_last[$j-2]:-${color_ind[$j-2]}}; \
;; \
*) \
case \"${graph_line_last:$j:1}\" in \
\"|\") \
color_ind[$j]=${color_ind_last[$j]:-${color_ind[$j]}}; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
esac; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
graph_colored=\"${graph_colored}\\033[${color[${color_ind[$j]}]}m$char$char\\033[0m\"; \
;; \
\"_\") \
case \"${graph_line:$(($j-2)):1}\" in \
\"\\\\\"|\"_\") \
color_ind[$j]=${color_ind[$j-2]}; \
;; \
\" \"|\"/\") \
k=2; \
while [[ \"${graph_line:$(($j+$k)):1}\" = \"_\" ]];do \
k=$(($k+2)); \
done; \
case \"${graph_line:$(($j+$k)):1}\" in \
\"/\") \
case \"${graph_line_last:$(($j+$k+1)):1}\" in \
\"*\") \
color_ind[$j]=${color_ind[$j+$k+1]}; \
;; \
\" \") \
case \"${graph_line_last:$(($j+$k)):1}\" in \
\"\\\\\") \
color_ind[$j]=${color_ind[$j+$k]}; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
\"|\") \
case \"${graph_line:$(($j+$k+1)):1}\" in \
\"|\") \
color_ind[$j]=${color_ind[$j+$k+2]}; \
;; \
\" \") \
color_ind[$j]=${color_ind[$j+$k+1]}; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
;; \
*) \
[[ -n \"$msg_err\" ]] && echo -e \"Unknown case in graph_line $i: $graph_line for char $char at position $j\nwith the former graph_line $(($i-1)): $graph_line_last\"; \
;; \
esac; \
graph_colored=\"${graph_colored}\\033[${color[${color_ind[$j]}]}m$char\\033[0m\"; \
;; \
esac; \
char_last=$char; \
done <<< \"$(grep -Eo \".\" <<< \"${graph_line%%$delim*}\")\"; \
for key in ${!color_ind[*]};do \
color_ind_last[$key]=${color_ind[$key]}; \
done; \
\
\
c=0; \
((l++)); \
[[ $l -gt $n ]] && l=1; \
while IFS= read -d\"$delim\" -r col_content;do \
((c++)); \
[[ $c -le $graph_col ]] && c_corr=-1 || c_corr=0; \
if [[ $c -eq 1 ]];then \
[[ \"${col_content/\\*}\" = \"$col_content\" ]] && [[ $l -eq 1 ]] && l=$n; \
whitespaces=$(seq -s\" \" $((${col_length[\"1:1\"]}-$j))|tr -d \"[:digit:]\"); \
col_content[$graph_col]=\"${graph_colored}$whitespaces\"; \
elif [[ ${col_colored[\"$l:$c\"]:-0} -eq 0 ]];then \
col_content[$c+$c_corr]=\"\\033[${point_color:-0}m$(printf \"%-${col_length[\"$l:$c\"]}s\" \"${col_content:-\"\"}\")\\033[0m\"; \
else \
col_content[$c+$c_corr]=\"$(printf \"%-${col_length[\"$l:$c\"]}s\" \"${col_content:-\"\"}\")\"; \
fi; \
done <<< \"$line$delim\"; \
for ((k=$c+1;k<=$i_max;k++));do \
[[ $k -le $graph_col ]] && c_corr=-1 || c_corr=0; \
col_content[$k+$c_corr]=\"$(printf \"%-${col_length[\"$l:$k\"]:-${col_length[\"${last[$k]:-1}:$k\"]:-0}}s\" \"\")\"; \
done; \
unset col_content[0]; \
echo -e \"${col_content[*]}\"; \
unset col_content[*]; \
done < <(git $1 && echo); \
"' "git-colored"
설명:
- 첫 번째 단락은 딜리미터, 컬러 리스트 및 YourLogAlias를 셸 변수에 로드합니다.
- 두 번째는 각 열의 길이를 읽어냅니다.
- 세 번째는 트리의 최대 길이를 계산합니다.
- 네 번째는 트리를 배열에 로드합니다.
- 다섯 번째 색상은 사례 분석에 따라 트리를 색칠합니다.
- 여섯 번째는 트리 이외의 열을 색칠하여 표와 같은 출력을 인쇄합니다.
가장 큰 부분은 트리 색상을 설정하기 위한 케이스 분석입니다.다른 부분은 표와 같은 셸 출력에 대한 링크된 답변에 설명되어 있습니다.
제 로그 에일리어스는 예시일 뿐이므로, 마음에 드는 포맷의 로그 에일리어스를 코멘트에 표시해 주세요.
git -c core.pager='less -SRF' log --oneline --graph --decorate
이것은 저의 최종적인 변화입니다.여기서 많은 답변과 비슷합니다.전달되는 플래그를 조정하는 것을 좋아합니다.less
단어 줄 바꿈을 방지합니다.
명령어가 조금 번거롭기 때문에 빠른 접근을 위해 에일리어스로 설정했습니다.
Git 저장소의 커밋 이력에 대한 PNG 또는 SVG 표현을 생성합니다.
저장소가 GitLab에 있는 경우 브라우저에서 SVG로 렌더링되는 그래프 표현을 사용할 수 있습니다.
저장소 그래프 보기로 이동합니다(예: https://gitlab.com/gitlab-org/gitter/webapp/network/develop).
그래프를 아래로 스크롤합니다(지속적인 부하 커밋).
브라우저의 인스펙터를 사용하여 SVG 요소를 새 파일에 복사합니다.
원하는 렌더러(예: Inkscape)에서 열기
디타아 먹어봐.ASCII 다이어그램을 이미지로 변환할 수 있습니다.Git 브랜치를 염두에 두고 설계한 것은 아니지만, 그 결과에 감동했습니다.
소스(txt 파일):
+--------+
| hotfix |
+---+----+
|
--*<---*<---*
^
|
\--*<---*
|
+---+----+
| master |
+--------+
명령어:
java -jar ditaa0_9.jar ascii-graph.txt
결과:
또한 배경색, 점선, 다양한 모양 등을 지원합니다.예를 참조해 주세요.
~/.oh-my-zsh/plugins/git/git.plugin 파일의 일부 별칭입니다.zsh:
gke='\gitk --all $(git log -g --pretty=%h)'
glg='git log --stat'
glgg='git log --graph'
glgga='git log --graph --decorate --all'
glgm='git log --graph --max-count=10'
glgp='git log --stat -p'
glo='git log --oneline --decorate'
glog='git log --oneline --decorate --graph'
gloga='git log --oneline --decorate --graph --all'
glol='git log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit'
glola='git log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit --all'
이 있습니다: ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★.git ls
★★★★★★★★★★★★★★★★git ls
그래프를 표시할 수 있으며 각 커밋은 한 줄만 포함합니다.모든 것에 색을 입히고 유용한 정보를 제공합니다.다른 브랜치에서도 커밋 이력을 확인할 수 있습니다.
git config --global alias.ls '!f() { git log $1 --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cgreen\\ [%ae,%ar]" --decorate --graph; }; f'
사용방법:
# shows commits graph on the current branch
git ls
# shows commits graph on the develop branch
git ls develop
그래프 뷰는 다음과 같습니다.
언급URL : https://stackoverflow.com/questions/1057564/pretty-git-branch-graphs
'programing' 카테고리의 다른 글
Python의 쌍별 교차 제품 (0) | 2023.04.18 |
---|---|
다트 목록에서 중복된 항목을 삭제하려면 어떻게 해야 합니까?list.filength()를 선택합니다. (0) | 2023.04.18 |
NSUserDefaults - 키가 존재하는지 확인하는 방법 (0) | 2023.04.18 |
앱스토어 앱 링크 방법 (0) | 2023.04.18 |
반환 값을 사용하여 스토어드 프로시저를 호출합니다. (0) | 2023.04.13 |