git : 커밋 메시지의 인덱스 차이를 주석으로 표시
때 git commit
열려있는 메시지 편집기 쇼 간단한 상태,이 같은 것입니다 :
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is ahead of 'origin/master' by 26 commits.
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: Showcase/src/com/gigantt/BorderArea.mxml
# modified: Showcase/src/com/gigantt/Client.mxml
# modified: Showcase/src/com/gigantt/GraphItem.mxml
#
커밋 할 diff도 표시하도록 git을 조정하려면 어떻게해야합니까? 나는 그것이 긴 차이 일 수 있다는 것을 알고 있지만 여전히 .. 매우 유용합니다.
에 대한 --verbose
(또는 -v
) 플래그는 git commit
커밋 될 항목의 차이를 표시합니다.
git commit --verbose
Alan의 답변에 대한 답변을 게시하기에 충분한 평판은 아니지만 Idan과 다른 사람을 위해 방금 시도했고 커밋 메시지의 diff 줄이 명시 적으로 주석 처리되지 않았습니다. 그러나 여전히 최종 커밋 메시지에 나타나지 않습니다. 감사합니다.
$ git commit --verbose
내 편집기에서 :
Feeling a bit pessimistic now.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README
#
diff --git a/README b/README
index af5626b..c62237e 100644
--- a/README
+++ b/README
@@ -1 +1 @@
-Hello, world!
+Goodbye, world!
( #
앞에 diff 라인 이 없다는 점에 유의하십시오 )
그리고 실제 커밋 메시지 :
$ git log -n 1
commit ad21a2655ef6d8173c2df08dc9893055b26bc068
Author: Tom Jakubowski <tom@crystae.net>
Date: Thu Oct 27 19:12:54 2011 -0700
Feeling a bit pessimistic now.
분명히 git show
diff는 여전히 표시되지만 항상 커밋하기 때문입니다. :)
.git / hooks / prepare-commit-msg 에 다음 줄을 넣어 주석 처리 된 diff를 얻었습니다.
#!/bin/bash
if [ "$2" == "" ] ; then
git diff --staged -p --stat 2> /dev/null | awk '{ printf "#"; print}' >> "$1" 2>/dev/null
fi
이렇게하면 diff를 주석 처리 할 수있을뿐만 아니라 더 많은 정보를 추가 할 수도 있습니다 ( stat 옵션 처럼 ).
편집 : 또한 git commit --verbose 는 커밋 메시지에 대한 diff를 포함하지 않습니다.
이 동작이 항상 존재 하는지 확인하는 가장 간단한 방법 은이 섹션을 git config
파일 에 추가하는 것입니다 .
[commit]
verbose = true
You may need to configure your editor to actually display in diff mode (for syntax highlighting). I use Notepad2 as a Windows Notepad replacement, and -s diff
sets the color scheme appropriately (red for deleted lines, etc.):
[core]
editor = C:/Windows/system32/notepad.exe -s diff
If you want to always see the diff when you commit, you can add the following to your ~/.gitconfig
file:
[alias]
commit = commit -v
참고URL : https://stackoverflow.com/questions/4750148/git-show-index-diff-in-commit-message-as-comment
'Programming' 카테고리의 다른 글
Visual Studio 2013에서 Git 통합을 영구적으로 비활성화하려면 어떻게해야합니까? (0) | 2020.08.09 |
---|---|
자식 요소를 변경하지 않고 요소의 텍스트를 어떻게 변경할 수 있습니까? (0) | 2020.08.09 |
Scala의 패턴 일치가 변수와 작동하지 않는 이유는 무엇입니까? (0) | 2020.08.09 |
가장 간단한 Socket.io 예제의 예는 무엇입니까? (0) | 2020.08.09 |
postgresql 외래 키 구문 (0) | 2020.08.09 |