Git: ignorar arquivos que já foram enviados a um repositório Git

30 de agosto de 2021 0 Por sudoroot

 Etapa 1: atualizar o arquivo.gitignore

Passo 2:
git rm -r --cached .

Etapa 3:
git add .

Resultado:

1
2
3
4
5
$ git add .
warning: LF will be replaced by CRLF in composer.json.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in composer.lock.
The file will have its original line endings in your working directory.

Etapa 4: comprometê-lo:
git commit -m "add .gitignore"

Resultado:

1
2
3
4
5
$ git commit -m "add .gitignore"
[master 5e7d42e] add .gitignore
 950 files changed, 177570 deletions(-)
 delete mode 100644 .bash_history
...

Etapa 5:
git push

Resultado:

1
2
3
4
5
6
7
8
9
$ git push
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 221 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
   8c7e959..5e7d42e  master -> master