> For the complete documentation index, see [llms.txt](https://favelaware.gitbook.io/favelaware/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://favelaware.gitbook.io/favelaware/3-git-e-github/3.4-comandos-basicos-do-git.md).

# 3.4 Comandos Básicos do Git

### 💻 Comandos Básicos do Git

Page description (optional)

🧠 **Por que aprender os comandos do Git?**

O Git é como uma máquina do tempo do seu código. Aprender os comandos básicos vai te ajudar a:

* Salvar versões do seu projeto ✅
* Voltar atrás se algo der errado 🔙
* Trabalhar em equipe sem bagunça 🤝

Vamos por partes. Respira fundo e vem comigo! 😮‍💨🚀

***

### 📁 Criando e Iniciando um Repositório

#### 1. **Começar a usar o Git em uma pasta**

```bash
git init
```

🗂️ Esse comando transforma uma pasta comum em um projeto Git.

> Exemplo:\
> Crie uma pasta chamada `meu-projeto`, entre nela e digite `git init`.\
> Agora o Git vai começar a acompanhar tudo que acontecer ali.

***

### 👀 Verificando o que mudou

#### 2. **Ver o que está acontecendo**

```bash
git status
```

🔍 Mostra os arquivos que você criou, modificou ou deletou e o que ainda falta salvar (*commit*).

***

### ➕ Adicionando arquivos para serem salvos

#### 3. **Preparar os arquivos para salvar**

```bash
git add nome-do-arquivo
```

📥 Diz ao Git: “quero salvar esse arquivo”.

> Exemplo:
>
> ```bash
> git add index.html
> ```

#### 3.1. **Adicionar tudo de uma vez**

```bash
git add .
```

🔥 Muito usado no dia a dia. Adiciona todos os arquivos modificados.

***

### 💾 Salvando uma versão do projeto

#### 4. **Salvar os arquivos com uma mensagem**

```bash
git commit -m "Mensagem do que foi feito"
```

📝 É como tirar uma foto do seu projeto naquele momento.

> Exemplo:
>
> ```bash
> git commit -m "Criei a página inicial"
> ```

***

### 🕰️ Histórico de versões

#### 5. **Ver o histórico de commits**

```bash
git log
```

📜 Mostra todas as versões salvas, quem fez, quando e com que mensagem.

> Use a tecla `q` para sair do log.

***

### 🔄 Voltando no tempo

#### 6. **Voltar para a última versão salva (descartar mudanças)**

```bash
git checkout -- nome-do-arquivo
```

⛔ Usado se você quer **desfazer mudanças antes de fazer o commit**.

> Exemplo:
>
> ```bash
> git checkout -- index.html
> ```

***

### 🌍 Ligando com repositórios remotos (tipo GitHub)

#### 7. **Clonar um repositório existente**

```bash
git clone link-do-repositorio
```

📥 Copia um projeto do GitHub para sua máquina.

> Exemplo:
>
> ```bash
> git clone https://github.com/usuario/repositorio.git
> ```

***

### ⬆️ Enviando para o GitHub

#### 8. **Enviar suas alterações para o GitHub**

```bash
git push origin main
```

🚀 Manda os commits para o repositório na nuvem.

***

### ⬇️ Baixando atualizações do GitHub

#### 9. **Receber alterações feitas por outras pessoas**

```bash
git pull origin main
```

🔄 Puxa as atualizações do repositório remoto.

***

### 🧪 Resumo dos principais comandos

| Ação                        | Comando                    |
| --------------------------- | -------------------------- |
| Iniciar um repositório      | `git init`                 |
| Ver status                  | `git status`               |
| Adicionar arquivo           | `git add nome-do-arquivo`  |
| Adicionar todos os arquivos | `git add .`                |
| Salvar versão (commit)      | `git commit -m "mensagem"` |
| Ver histórico               | `git log`                  |
| Clonar repositório          | `git clone link`           |
| Enviar para GitHub          | `git push origin main`     |
| Receber do GitHub           | `git pull origin main`     |

***

📣 **Dica final para iniciantes:**\
Você não precisa decorar tudo agora. Com o tempo e a prática, esses comandos vão se tornar naturais. Use este guia como referência sempre que precisar! 💪📘

***


---

# 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, and the optional `goal` query parameter:

```
GET https://favelaware.gitbook.io/favelaware/3-git-e-github/3.4-comandos-basicos-do-git.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
