Git 基礎設定 (帳號的環境參數設定)

Git 基本環境設定, 主要是設定自己帳號下的環境參數.

詳細內容可見: git help config

基本資料設定

直接於 Shell 下執行下述:

  1. git config --global user.name "Tsung"
  2. git config --global user.email "[email protected]"
  3. git config --global color.diff auto # git diff 要顯示顏色
  4. git config --global color.status auto # git status 要顯示顏色
  5. git config --global color.branch auto
  6. git config --global color.log auto # git log --graph 會很漂亮, 感謝日落提供.
  7. 註: 這些設定會在 ~user/ 下產生 .gitconfig

    [color]
    diff = auto
    status = auto
    branch = auto
    log = auto
    [user]
    name = Tsung
    email = [email protected]

Git 自動忽略檔案 / 目錄設定

要自動將某些檔案掠過不 Commit, 要設定 .gitignore 這個檔案. (哪些檔案是不要 commit 進去的)

  • vim .gitignore

    tmp/**/*
    log/*
    config/database.yml

  • 使用 git add . 等, 這些都不會將這些資料列入 commit. (.gitignore 會被列入 commit)

修改預設目錄

預設會產生 .git 目錄, 改成 .test

  • 修改 Shell 變數 GIT_DIR => export GIT_DIR=.test

相關網頁

作者: Tsung

對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.

在〈Git 基礎設定 (帳號的環境參數設定)〉中有 5 則留言

  1. color.ui
    This variable determines the default value for variables such as color.diff and color.grep that control the use of color per command family. Its scope will expand as more commands learn configuration to set a default for the --color option.
    git config --global color.ui auto

Tsung 發表迴響取消回覆

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料