.gitignore file documentation submitted negligible when -git

When we usually do on a project, there are always some documents did not want to submit to the server version management

Then you should set the appropriate rules to ignore, to ignore submit these documents

Rule action
/ mtk filter the entire folder
* .zip filtering all .zip files
/mtk/do.c filter a specific file
/mtk/one.txt track (no filter) to a specific file!
Note: If you create .gitignore to push a file before the file, even if you write filtering rules .gitignore the file in the file, the rule will not work, git will still perform the file version management.

If you want to re-enter into force (

.gitignore can ignore those files had not been the track, if some files have been included in the version management, modifying .gitignore is invalid.

The solution is to first delete the local cache (not track changes to the state), and then submitted to:

git rm -r --cached .
git add .
git commit -m 'update .gitignore'

Configuration syntax
slash "/" at the beginning represents the directory;
an asterisk "*" wildcard multiple characters;
"?" Question mark wildcard single character
in square brackets "[]" match list contains a single character;
with an exclamation mark " ! "said they did not ignore the (track) to match the file or directory.
Note: git for .gitignore profile by rows from the top down rule matching

Git ignore the rule-matching syntax

In .gitignore file, ignoring grammar rules of each line is as follows:

  • 空格Does not match any file can be used as the separator, usable backslash
  • # 开头The model identifies a comment, escaped with a backslash
  • ! 开头The model identifies the negative, the file will be included again, if you exclude the parent directory of the file, use the! Will not be included again. You can be escaped with a backslash
  • / 结束Pattern matching only the contents of the folder and in that folder path, but does not match the file
  • / 开始Pattern matching with the project directory
  • If the pattern does not contain a slash, it matches with the contents of the current file path .gitignore, if the pattern is not .gitignore file, with respect to the project root
  • **Matching multi-level directory, at the beginning, middle, end
  • ?Universal matches a single character
  • []Universal matches a single character list

 

---------------------------------------------

Another method does not require new .gitignore

This is only a temporary way to specify the behavior of the project, you need to edit .git / info under the current project / exclude file and need to ignore the documents submitted written.

It should be noted that the root directory specified in this way to ignore files is the project root directory.

 

Guess you like

Origin www.cnblogs.com/bobo1/p/11549899.html