As already stated in the comments, you can make use of the .gitignore
.
The .gitignore
is a file in which you specify other files that should not be screened, that is, it will ignore whether or not there are changes in these files.
If a file is already in your remote repository, say local.config
, and you add it to .gitignore
, the file will continue in the remote repository, but any local changes made to it will not be reflected in the remote repository as it is no longer being "tracked".
Search pattern
Every line in the file .gitignore
specifies a path that follows a pattern described in the documentation:
- Empty lines are ignored, so you can use them as a separator between groups of files;
#
at the beginning of the line makes it a comment;
spaces at the end of the line are ignored;
!
serves to ignore a pattern. For example, diretório/
ignore all files from the specified directory, but you can use diretório/!arquivo
to remove the arquivo
from the ignore list;
/
is used as a directory separator, if the bar /
is at the beginning or middle of the pattern, means this pattern will be applied in relation to at the directory level .gitignore
is;
/
at the end of the pattern indicates that it is a default for directories, otherwise it may be either directory or file;
*
corresponds to any characters except the bar /
;
?
corresponds to a single any character, with the exception of the bar /
;
**/
at the beginning corresponds to "any directory";
/**
at the end corresponds to "everything inside the directory";
/**/
corresponds to "zero or more directories".
Example
Given the following file and directory structure:
meuprojeto
├── app
│ ├── paginas
│ │ ├── .config
│ │ ├── contato.html
│ │ ├── home.html
│ │ ├── home.css
│ │ ├── home.js
│ │ ├── teste
│ │ ├── teste.html
│ │
│ ├── teste
│ │ ├── .config
│ │
│ ├── debug.log
│ ├── error.log
│ ├── error1.log
│ ├── error2.log
│ ├── error30.log
│ ├── example.log
│ ├── main.log
│
├── .config
├── .gitignore
We could have the following on .gitignore
:
# Ignorar qualquer arquivo ou diretório chamado `teste`, note que `teste.html` não é ignorado
teste
# Ignorar todos `.log` com exceção do `example.log`
*.log
!example.log
# Parar de ignorar os arquivos `error<identificador_1digito>.log`, note que `error30.log` continuará ignorado
!error?.log
# Ignorar o `.config` que está dentro de `paginas`
/app/paginas/.config
It’s not just adding it to . gitignore?
– Jéf Bueno
@LINQ do not know, even using git local not github to use . gitignore?
– Julio Cesar Stein