Skip to content

Instantly share code, notes, and snippets.

@samuelsilvati
Last active September 17, 2025 13:21
Show Gist options
  • Select an option

  • Save samuelsilvati/e4b660d40b798732f18fbf5b504c00c8 to your computer and use it in GitHub Desktop.

Select an option

Save samuelsilvati/e4b660d40b798732f18fbf5b504c00c8 to your computer and use it in GitHub Desktop.

Revisions

  1. samuelsilvati revised this gist Sep 17, 2025. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -121,6 +121,12 @@ git tag -d v1.0
    ```bash
    git push origin --delete tag v1.0
    ```
    ### Forçar atualização da tag
    Atualize os arquivos e em seguida a tag
    ```bash
    git tag -f v1.0.0
    git push origin v1.0.0 --force
    ```

    Autor: Samuel Silva
    Licença: MIT
  2. samuelsilvati revised this gist Jul 4, 2025. 1 changed file with 34 additions and 0 deletions.
    34 changes: 34 additions & 0 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -88,5 +88,39 @@ git rebase main
    ```bash
    git log --oneline --graph --all
    ```
    ## 🔖 Trabalhar com Tags
    ### Criar uma tag leve (lightweight)
    ```bash
    git tag v1.0
    ```
    ### Criar uma tag anotada (com mensagem e autor)
    ```bash
    git tag -a v1.0 -m "Versão 1.0 lançada"
    ```
    ### Ver todas as tags do repositório
    ```bash
    git tag
    ```
    ### Ver detalhes de uma tag anotada
    ```bash
    git show v1.0
    ```
    ### Enviar tags para o repositório remoto
    ```bash
    git push origin v1.0
    ```
    ### Enviar todas as tags de uma vez
    ```bash
    git push origin --tags
    ```
    ### Deletar uma tag local
    ```bash
    git tag -d v1.0
    ```
    ### Deletar uma tag remota
    ```bash
    git push origin --delete tag v1.0
    ```

    Autor: Samuel Silva
    Licença: MIT
  3. samuelsilvati renamed this gist Jun 25, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. samuelsilvati renamed this gist Jun 25, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. samuelsilvati created this gist Jun 25, 2025.
    92 changes: 92 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,92 @@
    # 🧠 Git – Comandos úteis para trabalhar com Branches

    Um guia rápido com os comandos mais utilizados para criar, alternar, deletar e sincronizar branches, além de copiar commits específicos entre branches com `git cherry-pick`.

    ---

    ## 📌 Criar nova branch

    ```bash
    git checkout -b nome-da-branch # Cria e troca para a nova branch.
    ```

    ## 🔄 Trocar de branch

    ```bash
    git checkout nome-da-branch
    # ou no Git 2.23+
    git switch nome-da-branch
    ```
    ## ❌ Deletar branch local
    ```bash

    git branch -d nome-da-branch # Deleta branch (se já tiver sido mesclada)
    git branch -D nome-da-branch # Força a exclusão da branch
    ```
    ## ❌ Deletar branch remota
    ```bash
    git push origin --delete nome-da-branch
    ```
    ### ⬆️ Enviar branch local para o repositório remoto
    ```bash
    git push -u origin nome-da-branch
    ```
    ## 🔁 Atualizar sua branch local com a versão remota

    ```bash
    git fetch origin
    git checkout nome-da-branch
    git merge origin/nome-da-branch
    ```
    ### Ou para forçar a cópia exata do remoto (⚠️ sobrescreve alterações locais):

    ```bash
    git reset --hard origin/nome-da-branch
    ```
    ## 🔄 Sincronizar todas as branches remotas

    ```bash
    git fetch --all --prune
    # O --prune remove referências locais a branches que foram deletadas do remoto.
    ```

    ## 🔍 Listar branches
    ```bash
    git branch # Branches locais
    git branch -r # Branches remotas
    git branch -a # Todas as branches
    ```
    ## 🪄 Copiar commit de outra branch (cherry-pick)
    ```bash
    git checkout minha-branch
    git cherry-pick <hash-do-commit>
    ```
    ## Copia um commit específico para sua branch atual.

    ### Para múltiplos commits:
    ```bash
    git cherry-pick <hash-inicial>^..<hash-final>
    ```
    ## 🔧 Renomear uma branch
    ```bash
    git branch -m novo-nome
    ```
    ### Ou renomear uma branch diferente da atual:
    ```bash
    git branch -m nome-antigo novo-nome
    ```
    ## 🔄 Atualizar sua branch com outra branch (ex: trazer mudanças da main)
    ```bash
    git checkout minha-branch
    git merge main
    ```
    ### Ou com rebase (mantém histórico linear):
    ```bash
    git rebase main
    ```
    ## 🧭 Visualizar histórico de commits
    ```bash
    git log --oneline --graph --all
    ```
    Autor: Samuel Silva
    Licença: MIT