我從~/.gitconfig
刪除我的憑據,但是當我運行git commit -m "some crap"
它仍然有我名字的承諾。我刪除了我的電子郵件和尼克gitconfig,但它仍然能夠提交
我怎樣才能阻止它能夠承諾?我需要在我的程序中測試一些功能,它需要git commit
命令失敗。
我從~/.gitconfig
刪除我的憑據,但是當我運行git commit -m "some crap"
它仍然有我名字的承諾。我刪除了我的電子郵件和尼克gitconfig,但它仍然能夠提交
我怎樣才能阻止它能夠承諾?我需要在我的程序中測試一些功能,它需要git commit
命令失敗。
Git
需要作者的電子郵件從幾個地方,如果它不以任何這些地方找到它,它會自行創建它。見man git-config
:
user.email
Your email address to be recorded in any newly created commits. Can be overridden by the GIT_AUTHOR_EMAIL,
GIT_COMMITTER_EMAIL, and EMAIL environment variables. See git-commit-tree(1).
所以,在上面的評論,首先檢查說,如果你有.git/config
配置電子郵件,下次檢查在手冊頁中列出的所有變量。這是很難做出的,因爲缺乏電子郵件git commit
失敗,因爲即使它沒有明確設定有可能做出承諾,至少在Linux
:
$ touch 1243
$ git add 1243
$ git commit -mm
[email-test eab3127] m
Committer: Arkadiusz Drabczyk <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email [email protected]
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 1243
$ echo $?
0
編輯:話雖這麼說,我喜歡使用EMAIL
變量,因爲它也是由其他程序,如doxygen
或mutt
不僅git
理解爲設置我的電子郵件。
@Arkdaiusz,謝謝您的回答。這個交易是我需要用我們的軟件測試報告的錯誤,用戶說如果我們設置這樣的憑證,那麼'git config --global user.name''''在提交時軟件將失敗。那麼,你說這是不可能的?此外,我只能使用普通的'git commit'命令,但我可以刪除並刪除任何導致錯誤的憑據。我會問他提供更多信息。 – pushandpop
也許它的憑證範圍不是項目全球。檢查你的項目的.gitconfig或運行'git config user.name「你的名字」'。這將覆蓋您的項目特定配置。 – Ramin
檢查'git的/ config' – 2016-01-13 19:07:18