Use file .gitignore ignore Git repository

.gitignore

In Git, a lot of times you just want to submit code to the repository, rather than the file in the current directory of all the files submitted to the Git repository, such as MacOS system in the following .DS_Storefile or record Xocde of operation, or a pod in a long list of library source code. In this case use .gitignorecan automatically ignore these files submitted in Git.

Ignore format

  • # : This is a comment - will be ignored Git
  • *.a: Ignore all .afiles ending in
  • !lib.a: Do not Ignore lib.afile
  • /TODO: Just ignore the next project root directory TODOfiles are not includedsubdir/TODO
  • build/: Ignore build/all files in a directory
  • doc/*.txt: Ignore doc/notes.txtbut does not includedoc/server/arch.txt

Creation Method

From github get on

Compiled some common needs on github project file configuration to be ignored, be acquired as needed

https://github.com/github/gitignore.git

Three related files in Xcode

  • Xcode.gitignore
  • Objective-C.gitignore
  • Swift.gitignore

Xcode.gitignoreIgnore the Xcodeconfiguration information, such as recording operation, by default windows, etc.

In the other two Xcode.gitignorewere ignored for different languages on the basis of

These files will rewrite named .gittignore

$ mv Swift.gitignore .gittignore

By gitignore.io created (recommended)

First Custom Terminal command:

macOS default is \#!/bin/bash:

$ echo "function gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}" >> ~/.bash_profile && source ~/.bash_profile

if #!/bin/zsh

$ echo "function gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}" >> ~/.zshrc && source ~/.zshrc
use

In the current terminal directory

$ gi swift > .gitignore

Swifit will be created for the type of project .gitignorefiles.

** If you want to know more, please pay attention to micro-channel public number **
![](https://img2018.cnblogs.com/blog/1821244/201910/1821244-20191003144309271-650860871.jpg)

Guess you like

Origin www.cnblogs.com/mrChangChang/p/11619771.html