Créer une branche et se positionner dessus:
git checkout -b nombranche
Pusher la nouvelle branche sur un repository distant
git push origin nombranche
Supprimer une branche localement:
git branch -d nombranche
Propager la suppression sur le repository distant:
git push origin :nombranche
Fusion de commits (les deux derniers, mais peut être répété autant de fois que nécessaire):
git reset --soft HEAD~1 git commit -a --amend
Faire un checkout d’une branche distante:
git checkout -b nombranchelocal origin/nombranchedistante
Supprimer un fichier versionné accidentellement:
git pull git filter-branch --index-filter 'git rm --cached --ignore-unmatch nomfichier' --prune-empty --tag-name-filter cat -- --all echo "nomfichier" >> .gitignore git add .gitignore git commit -m "Ajout de nomfichier a .gitignore" git push origin master --force
Rebase pour appliquer les changements de la branche master distante sur une branche locale spécifique:
git checkout master # on se positionne sur notre branche master git pull # on la met à jour par rapport au repository distant git checkout nombranche # on se positionne sur la branche nombranche git rebase master # on tente d'appliquer les changements fait dans master # en cas de conflit, les résoudre et faire "git rebase --continue"
Il est également possible d’utiliser le mode interactif:
git rebase -i master