我在不同的計算機上密集使用不同用戶名的Git。有時候,當我克隆一個倉庫,我忘記配置user.name
和user.email
,當我犯了第一個提交到本地倉庫沒有指定的標識名稱,我得到如果未配置user.name和user.email,則在Git中中止提交
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
是的,這是完全清楚和爲什麼Git這樣說。 (但是,如果我注意到它。)但是,是否可以抑制這種行爲並使Git不會將我的用戶名和主機名作爲提交作者用戶名傳播?爲什麼我問的問題是,我的[user] name =
和[user] email =
都沒有在我的~/.gitconfig
中:我只是針對不同的存儲組使用不同的用戶名和電子郵件,我希望Git只是在無法獲得用戶名時中止提交來自配置的電子郵件。最糟糕的是我有一個自定義的Git-informative PS1
配置顯示當前的存儲庫用戶名和電子郵件的權利,因爲我有歷史重寫和強制推送幾次,甚至沒有注意到巨大的Git警告用戶名默認。
如果全局未指定user.name
和user.email
,是否可以放棄Git中的提交? (我想它可以通過掛鉤是固定的,但掛鉤是本地唯一的,對吧?)
雖然我希望它是簡單的。我感到羞愧,因爲我無法看到這個選項,以及我無法有時閱讀我的'PS1'......謝謝! –
有趣的細節:'user.useConfigOnly'似乎不起作用,如果'.gitconfig'中的'user ='和'email ='沒有值(我的意思是'= \ n')並且沒有被註釋掉。 –