2010-12-07

[Git] 一些基本的環境設定 (2010/12/15 Update!)

使用 git 第一步是設定你的基本資料,也就是 user name 跟 user email

$ git config --global user.name "username"
$ git config --global user.email "username@email.com"

設定顯示顏色
$ git config --global color.diff auto
$ git config --global color.status auto
$ git config --global color.branch auto
$ git config --global color.log auto

設定會存在 ~/.gitconfig
或者可以下指令看
$ git config -l

自訂 log 格式到 lg,當然你也可以定義其他 alias
$ git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"


讓 Git 忽略特定檔案


使用者自行建立名為 .gitignore 的檔案
ex.
# 註解,會被忽略。
*.a       # 不要追蹤檔名為 .a 結尾的檔案
!lib.a    # 但是要追蹤 lib.a,即使上方已指定忽略所有的 .a 檔案
*.swp
*~

或是,只想要忽略當前的 repository 中的檔案
將檔案設定加到 .git/info/exclude 中就可以了

沒有留言 :

張貼留言