在最近有一個同事問了我一個問題,平常 Git 都是使用私人的 Email 在 Commit,但是公司的專案要用不同的 Mail 要怎麼處理呢?
在這邊教大家兩個方法來達成這件事情
方法一
如果只有一個 commit 需要修改 name 跟 email,推薦使用以下方法:
git commit -m "Commit message" --author "Your Name <email>"
方法二
如果希望以後某個資料夾下面都使用特定的 name 跟 email commit,推薦使用以下方法:
修改 ~/.gitconfig
[includeIf "gitdir:~/github/"] path = ~/github/.gitconfig [includeIf "gitdir:~/work/"] path = ~/work/.gitconfig
修改各個資料夾底下的 .gitconfig
以範例為例子需要修改 ~/github/.gitconfig
與 ~/work/.gitconfig
改成如下:
[user] name = Clarence email = [email protected]
[user] name = Clarence email = [email protected]
修改完在對應的資料夾下面 commit 就會是對應的 name 與 email 了!
結論
以上是一些在用 Git 可能會有需求用到的功能,希望有幫助到大家 ~
參考資料
《AWS CDK 完全學習手冊:打造雲端基礎架構程式碼 IaC》
第 12 屆 iT 邦幫忙鐵人賽 DevOps 組冠的《用 CDK 定 義 AWS 架構》
第 11 屆 iT 邦幫忙鐵人賽《LINE bot 好好玩 30 天玩轉 LINE API》
一個熱愛分享的雲端工程師!