Files
tldr/pages.fr/common/git-branch.md
2021-05-01 12:49:31 -04:00

37 lines
944 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# git branch
> Commande Git principale pour travailler avec des branches.
> Plus d'informations : <https://git-scm.com/docs/git-branch>.
- Liste les branches locale en préfixant la branche courante avec `*` :
`git branch`
- Liste toutes les branches (locale et distantes) :
`git branch -a`
- Affiche le nom de la branche courante :
`git branch --show-current`
- Crée une nouvelle branche depuis le commit courant :
`git branch {{nom_de_branche}}`
- Crée une nouvelle branche depuis un commit en particulier :
`git branch {{nom_de_branche}} {{commit_hash}}`
- Renommer une branche (ne pas se trouver sur la branche pour le faire) :
`git branch -m {{ancien_nom_de_branche}} {{nouveau_nom_de_branche}}`
- Supprimer un branche locale (ne pas se trouver sur la branche pour le faire) :
`git branch -d {{nom_de_branche}}`
- Supprimer une branche distante :
`git push {{nom_distant}} --delete {{nom_de_branche_distante}}`