Introdução ao Git
George Boorman
Curriculum Manager, DataCamp

Restaurar um repositório ao estado antes do commit anterior
git revert
a845edcb, ebe93178, etcHEAD, HEAD~1, etcgit revert HEAD
git revert HEAD

Ctrl + O, depois EnterCtrl + X[main 7d11f79] Revert "Adding fresh data for the survey."
Date: Tue Jul 30 14:17:56 2024 +0000
1 file changed, 3 deletions(-)
git revert --no-edit HEAD
git revert -n HEAD
git revert funciona em commits, não arquivos individuais
Para reverter um único arquivo:
git checkoutHEAD git checkout HEAD~1 -- report.md
git status
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: report.md
git commit -m "Checkout previous version of report.md"
[main daa6c87] Checkout previous version of report.md
1 file changed, 1 deletion(-)


git restore --staged summary_statistics.csv
git add summary_statistics.csv
git commit -m "Adding age summary statistics"
git restore --staged
| Comando | Resultado |
|---|---|
git revert HEAD |
Reverter todos arquivos de um commit |
git revert HEAD --no-edit |
Reverter sem abrir editor de texto |
git revert HEAD -n |
Reverter sem fazer um novo commit |
git checkout HEAD~1 -- report.md |
Reverter um único arquivo do commit anterior |
git restore --staged report.md |
Remover um único arquivo da área de preparação |
git restore --staged |
Remover todos arquivos da área de preparação |
Introdução ao Git