通常咱們總會有些文件無需歸入 Git 的管理,也不但願它們總出如今未跟蹤文件列表。 一般都是些自動生成的文件,好比日誌文件,或者編譯過程當中建立的臨時文件等。 在這種狀況下,咱們能夠建立一個名爲.gitignore
的文件,列出要忽略的文件模式。 來看一個實際的例子:git
$ cat .gitignore*.[oa]*~
第一行告訴 Git 忽略全部以 .o
或 .a
結尾的文件。通常這類對象文件和存檔文件都是編譯過程當中出現的。 第二行告訴 Git 忽略全部以波浪符(~)結尾的文件,許多文本編輯軟件(好比 Emacs)都用這樣的文件名保存副本。 此外,你可能還須要忽略 log,tmp 或者 pid 目錄,以及自動生成的文檔等等。 要養成一開始就設置好 .gitignore 文件的習慣,以避免未來誤提交這類無用的文件。github
文件 .gitignore
的格式規範以下:正則表達式
全部空行或者以 #
開頭的行都會被 Git 忽略。shell
可使用標準的 glob 模式匹配。windows
匹配模式能夠以(/
)開頭防止遞歸。ui
匹配模式能夠以(/
)結尾指定目錄。spa
要忽略指定模式之外的文件或目錄,能夠在模式前加上驚歎號(!
)取反。日誌
所謂的 glob 模式是指 shell 所使用的簡化了的正則表達式。 星號(*
)匹配零個或多個任意字符;[abc]
匹配任何一個列在方括號中的字符(這個例子要麼匹配一個 a,要麼匹配一個 b,要麼匹配一個 c);問號(?
)只匹配一個任意字符;若是在方括號中使用短劃線分隔兩個字符,表示全部在這兩個字符範圍內的均可以匹配(好比 [0-9]
表示匹配全部 0 到 9 的數字)。 使用兩個星號(*
) 表示匹配任意中間目錄,好比a/**/z
能夠匹配 a/z
, a/b/z
或 a/b/c/z
等。code
咱們再看一個 .gitignore 文件的例子:orm
# no .a files *.a # but do track lib.a, even though you're ignoring .a files above !lib.a # only ignore the TODO file in the current directory, not subdir/TODO /TODO # ignore all files in the build/ directory build/ # ignore doc/notes.txt, but not doc/server/arch.txt doc/*.txt # ignore all .pdf files in the doc/ directory doc/**/*.pdf
GitHub 有一個十分詳細的針對數十種項目及語言的 .gitignore
文件列表,你能夠在https://github.com/github/gitignore 找到它.
參考博文:點擊
Basically you just need to add lines to ~/.gitconfig(若是你在windows下面 可能就在你的帳戶下面c:\Users\userXX\.gitconfig,這個文件是設置全局變量的地方)
[alias] st = status ci = commit -v
Or you can use the git config alias command:
$ git config --global alias.st status $ git config --global alias.ci 'commit -v'
若是你在windows下面你可能須要用單引號替換雙引號。
if you're using Git on Windows command line, then you will need to use double quotes "
instead of single quotes when adding command with spaces, e.g. git config --global alias.ci "commit -v"