Skip to main content

git

Afficher l'état de la branche en cours : 

git status

Ajouter des modifications à un commit : 

git add <chemin vers mon fichier>

Commit : 

git commit -m "Mon message de commit"

Envoie du commit : 

git push

Récupération des derniers commits distants : 

git pull

Supprimer le dernier commit : 

git reset --hard HEAD~1

Options : 

  • hard 
    • supprime le commit et enlève tes changements en local
  • mixed
    • supprime le commit de la staging area mais les changements en local (retours à l'état nécessitant un git add xxxx). 
  • soft
    • supprime le commit mais reste dans la staging area (après un git add xxxx), plus qu'à re- commit ! 

Changer de branche : 

git checkout <nom de ma branche>

Astuces : 

Tu t'es trompé de branches et tu veux pas perdre ton code ? 

Sauvegarder ton code dans un tampon : 

git stash

Fait ton changement de branche :

git checkout ....

Applique ton code en mémoire tampon : 

git statch pop