> For the complete documentation index, see [llms.txt](https://cumbucadev.gitbook.io/github-essentials/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cumbucadev.gitbook.io/github-essentials/dia-4/desfazendo-alteracoes-localmente/unindo-os-pontos.md).

# Unindo os Pontos

## Desfazendo Alterações Antes do Commit

* **`git restore <arquivo>`**: Este comando é usado para desfazer as mudanças feitas em um arquivo que ainda não foi comprometido. Ele **restaura o arquivo** para o estado que estava no último commit ou na área de staging, descartando as modificações feitas.

## Desfazendo Commits

* **`git revert hash-do-commit:`** Este comando cria um novo commit que reverte as alterações de um commit específico. Isso é útil quando você deseja desfazer algo que já foi feito, mas não quer afetar outros commits feitos depois desse.

## Alterando o Último Commit

* **Corrigir a mensagem do último commit:**

  ```sh
  git commit --amend -m "Nova mensagem do commit"
  ```
* **Adicionar arquivos esquecidos ao último commit:**

  ```bash
  git add arquivo_esquecido.txt  
  git commit --amend --no-edit  
  ```
* **Modificar o último commit (adicionar arquivos e alterar a mensagem):**

  ```bash
  git add arquivo_esquecido.txt  
  git commit --amend -m "Nova mensagem com arquivos adicionados"  
  ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cumbucadev.gitbook.io/github-essentials/dia-4/desfazendo-alteracoes-localmente/unindo-os-pontos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
