Tutoriel Git
1/ Récupérer une branche distante.
Lien : https://www.freecodecamp.org/news/git-checkout-remote-branch-tutorial/
- Déplacement vers la branche master :
git checkout master
- Récupérer toutes les branches distantes :
git fetch origin
- Afficher les branches :
git branch -a
- Récupérer une branche :
git checkout -b feature origin/feature
2/ Merge d'un commit de la branche feature sur master.
Lien : https://riptutorial.com/git/example/2188/copying-a-commit-from-one-branch-to-another
- Déplacement vers la branche master :
git checkout master
- Récupérer le commit de la branche feature :
git cherry-pick 653ad38
- Pousser le nouveau commit :
git push origin master
3/ Supprimer un gros fichier dans un commit.
- Afficher la liste des fichiers d'un commit afin d'identifier le gros fichier :
git show --pretty="" --name-only <commit id>
- Supprimer le fichier dans les fichiers dans tous les commits :
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch GROS-FICHER' --prune-empty --tag-name-filter cat -- --all
4/ Merger une branche sur master.
- Récupérer toutes les branches distantes :
git fetch origin
- Merger la branche :
git merge origin/autrebranche
- Push les commits sur master :
git push origin master
5/ Changer le nom et l'email de précédent commit.
Ouvrir :
changeNameEmail.sh
Ajouter :
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags