2010-03-14 49 views

回答

8

使用git log拉出的電子郵件地址。

例如,在post-receive

#!/bin/sh 

# Use the email address of the author of the last commit. 
export USER_EMAIL=$(git log -1 --format=format:%ae HEAD) 
$(dirname $0)/post-receive-email 

您也可以映射的電子郵件地址,例如如果人們使用他們的Gmail或個人域名地址,但你想將它們映射到一個單一的域。

#!/bin/sh 

# Use the mapped email address (specified in .mailmap) of the author of the last commit. 
export USER_EMAIL=$(git log -1 --format=format:%aE HEAD) 
$(dirname $0)/post-receive-email 

你可以閱讀更多關於.mailmaphere

#! /bin/sh 
git config hooks.envelopesender $(git log -all -1 --pretty=format:%ae) 
. /usr/share/git-core/contrib/hooks/post-receive-email 

git log HEAD

git log --all而是將使用最新的 提交所有分支上,按說:

+0

在較新的git它的git log -1 --pretty = format:%ae – 2ni 2011-04-26 10:31:33

+1

它不適用於分支機構。如果某人在分支機構中進行提交,那麼提交者將始終是主機中的最後一個。 – 2ni 2011-04-27 01:29:52

+0

你說得對,我有你提到的分支問題。你知道如何解決它嗎?它從來沒有讓我感到足夠的困擾,以查看它。 – 2011-04-27 20:25:13

1

下可能會更好,要正確處理好犯下的 分支(Debian的系統上使用)製成正確的一個通知。

git config hooks.envelopesender可能被替換爲另一個 上述變種。因人而異。

相關問題