Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git 的指令和設定
  6. Git config 指令
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

Git config 指令


設定使用者名稱和電子郵件

$ git config --global user.name <username>
$ git config --global user.email <mailaddress>

如果沒有--global選項,此設定將僅套用於特定儲存庫。

彩色顯示輸出

$ git config --global color.ui auto

為指令設定別名

$ git config --global alias.<aliasname> <commandname>

從版本控制追蹤中刪除檔案

$ echo <filename> >> .gitignore

.gitignore檔案下新增檔案路徑。Git 將不再管理這些檔案。您必須提交.gitignore檔案才能發揮作用。

在版本控制下追蹤空目錄

$ cd <dirname>
$ touch .gitkeep

Git 不會追蹤空目錄。如果您想將其新增到版本控制中,則需要在該目錄中放置一個檔案。人們通常做的一個常見做法是在空目錄中新增一個.gitkeep檔案。

顯示設定

$ git config --global --list

設定與代理伺服器的 HTTP 連線

將以下設定新增到.gitconfig檔案的 http 項。

[http]
  proxy = <address of the proxy server>:<port of the proxy server>

您也可以使用以下 config 指令對其進行設置:

$ git config --global http.proxy <address of the proxy server>:<port of the proxy server>

建立到使用者認證代理伺服器的 HTTP 連線

將以下設定新增到.gitconfig檔案的 http 項。

[http]
  proxy = http://<username>:<password>@<address of the proxy server>:<port of the proxy server>

您也可以使用以下 config 指令對其進行設置:

$ git config --global http.proxy http://<username>:<password>@<address of the
  proxy server>:<port of the proxy server>

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life