Git Ignore
$ touch dados.log
$ mkdir bin
$ touch bin/main.exe
$ git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
bin/
dados.log
nothing added to commit but untracked files present (use "git add" to track)$ touch .gitignore
$ cat "dados.log" >> .gitignore
$ cat "bin/" >> .gitignore
$ cat .gitignore
dados.log
bin/
$ git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
nothing added to commit but untracked files present (use "git add" to track)
$ git add .gitignore
$ git commit -m "Adicionando o GitIgnore"
[main c8aca07] Adicionando o GitIgnore
1 file changed, 3 insertions(+)
create mode 100644 .gitignore
$ git status
On branch main
nothing to commit, working tree clean
Padrão
Padrão
Arquivos e pastas afetados
Explicação
**/bin
bin/exemplo.log bin/pasta/arquivo.txt pasta/bin/log.txt
Com o duplo * é possível especificar qualquer ocorrência anterior
*/bin/debug.log
bin/debug.log build/bin/debulg.log
Pode haver combinação da estrutura de pastas e arquivos
*.log
debug.log logs/debug.log
Considera qualquer ocorrência
!bin/*.log
bin/debug.log
A exclamação ! representa negação
teste
teste/ teste teste.log
Sem / qualquer ocorrência será considerada, arquivo ou pasta
node_modules/
node_modules/teste.js node_modules/arquivo.js
Arquivos e pastas serão consideradas recursivamente
Last updated