git config 設定筆記


分類

建立時間: 2023年10月27日 15:03
更新時間: 2024年3月28日 11:55

說明

紀錄一些常用的 git config 設定。

設定項目

$ git config credential.helper 'store [<options>]'

在硬碟上儲存憑證的助手。

該命令在硬碟上無限期地儲存憑證,供未來的 Git 程式使用。

憑證預設會儲存在 ~/.git-credentials

儲存格式

.git-credentials 檔案是以明文儲存的。每個憑證都以 URL 的形式儲存在自己的一行中,例如:

https://user:pass@example.com

需留意安全性問題。

範例

$ git config credential.helper store
在當前倉庫儲存憑證。

$ git config --global credential.helper store
全域儲存憑證,所有倉庫都可用。


$ git config --global core.editor vim
Git 指定不同的編輯器,像編輯提交訊息會用到。

$ git config --global core.editor "'C:\Vim\vim90\vim.exe'"
使用完整路徑指定編輯器。


$ git config --global user.name "John Doe"
設定使用者名稱,每次 Git 的提交會使用這些資訊。


$ git config --global user.email johndoe@example.com
設定使用者 email,每次 Git 的提交會使用這些資訊。


查詢

輸入 git config <key> 來檢視某個設定目前的值。

$ git config user.name
John Doe

參考

觀看次數: 225
configgit
按讚追蹤 Enjoy 軟體 Facebook 粉絲專頁
每週分享資訊技術

一杯咖啡的力量,勝過千言萬語的感謝。

支持我一杯咖啡,讓我繼續創作優質內容,與您分享更多知識與樂趣!