前言
當我們使用 git 提交代碼的時候,發現賬號和郵箱是之前同事配置的,這時候需要改成自己的賬號,那么如何修改 git 的 config 配置文件?
就算卸載 git 重新安裝也沒用,之前的配置文件還是在的。
git 查看全部配置
先查看本地的 config 配置文件內容
git config --list

這時候看到 user.name 和 user.eamil 並不是自己的
刪除全局 config 配置
使用以下命令刪除其中一個配置項
git config --global --unset configname
刪除后,再去查看就沒有了

添加 config 配置
再把自己的 git 賬號和郵箱添加到 config 配置
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

這樣我們的配置就改回來了
config 增刪改查操作
新增
git config --global --add configname configvalue
刪除
git config --global --unset configname
修改
git config --global configname configvalue
查詢
git config --global configname
查詢全部
git config --list
