Skip to content

Git

Overview

Git is a free and open source distributed version control system. Here are the official documentations and those for liaoxuefeng's wiki.

.gitignore

**Notes: **

Principle
  1. Ignore files automatically generated by the system or environment, such as thumbnails by Windows, .idea directory by IntelliJ IDEA.
  2. Ignore intermediate files generated from compiling, such as .class compiled by Java.
  3. Ignore files that contain private information, such as configuration file of password or token.
Rules
  1. A blank line matches no files.
  2. A line starting with # serves as a comment.
  3. An optional prefix ! which negates the pattern. It is not possible to re-include a file if a parent directory of that file is excluded.
  4. The slash / is used as the directory separator.
  5. If there is a separator / at the end of the pattern then the pattern will only match directories.
  6. ** matches multi-directories.
  7. ? and [] are the same as those in regular expression.

For example:

  1. /dir to ignore the whole directory
  2. *.zip to ignore all the files ending with '.zip'
  3. /dir/main.txt to ignore the specified file
  4. !/dir/main.txt not to ignore the file
Notes

Files already tracked by Git are not affected. To stop tracking a file that is currently tracked, use git rm --cached.

$ git rm -r --cached target
$ git commit -m '.gitignore'