通常咱们总会有些文件无需归入 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"