Last active
September 10, 2025 20:17
-
-
Save ppsilv/053b02eae0726c0ff2343507ada720a1 to your computer and use it in GitHub Desktop.
Busca de commit antigo e criação de branch e tag a partir dele
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git checkout 3dcf0a10ab13855358c8c9ada30498ce773cd2be | |
| criar uma branch do checkout atual: | |
| git checkout -b stable-base | |
| stable-base é o nome da branch ponha um de sua preferência para se | |
| referir à nova branch. | |
| cria uma tag do checkout atual: | |
| git tag v1.0-stable | |
| v1.0-stable é o nome da tag ponha um de sua preferência para se | |
| referir à nova tag. | |
| Agora faça o upload para o github | |
| git push origin stable-base | |
| git push origin v1.0-stable | |
| Vai pedir usuario e senha atualmente a senha é o token criado. | |
| Boas práticas com o git | |
| # 1. Marco inicial (JÁ FEITO!) | |
| git checkout stable-base | |
| # 2. Para cada funcionalidade: | |
| git checkout stable-base | |
| git checkout -b feature-peek # Primeiro PEEK | |
| # ... desenvolve, testa, COMMITA | |
| git checkout stable-base | |
| git checkout -b feature-poke # Depois POKE | |
| # ... desenvolve, testa, COMMITA | |
| git checkout stable-base | |
| git checkout -b feature-while # Por último WHILE | |
| # ... desenvolve, testa, COMMITA | |
| # 3. Quando tudo testado e funcionando: | |
| git checkout master | |
| git merge feature-peek | |
| git merge feature-poke | |
| git merge feature-while | |
| # 4. Atualiza stable-base com as novas funcionalidades | |
| git checkout stable-base | |
| git merge main | |
| # Lista todas as branches locais | |
| git branch | |
| # Lista todas as branches (incluindo remotas) | |
| git branch -a | |
| # Procure pela sua branch específica | |
| git branch | grep nome-da-sua-branch | |
| # Mude para a branch | |
| git checkout nome-da-sua-branch | |
| # Ou se não encontrar, tente listar todas | |
| git branch --list "*nome*" | |
| # Procure por commits recentes em todas as branches | |
| git log --oneline --graph --all | |
| # Ou procure por uma mensagem de commit específica | |
| git log --all --grep="palavra-chave" | |
| # Lista todas as branches e seus últimos commits | |
| git branch -v | |
| # Mostra o reflog - histórico de todas as ações no git | |
| git reflog | |
| # Procure por checkout ou branch creation | |
| git reflog | grep -i "checkout\|branch\|create" | |
| # Mude para a branch | |
| git checkout nome-da-branch | |
| # Crie uma nova branch para garantir | |
| git checkout -b recuperacao-nome-da-branch | |
| # Faça push para o remote para não perder | |
| git push origin recuperacao-nome-da-branch | |
| # Procure por commits que não estão em nenhuma branch | |
| git fsck --lost-found | |
| # Ou use esta abordagem | |
| git log --reflog --oneline | |
| #!/bin/bash | |
| # Procura por branches locais que podem não estar listadas | |
| for ref in $(git for-each-ref --format='%(refname)' refs/heads/ refs/remotes/ refs/tags/); do | |
| echo "Verificando: $ref" | |
| git log --oneline -5 $ref | |
| echo "---" | |
| done | |
| #Volta para esse comit perdendo todas as alterações feitas que não foram comitadas. | |
| git reset --hard 238fff2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment