« Git Commandes » : différence entre les versions

Aucun résumé des modifications
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
==Log==
== '''Log''' ==
=== Voir les commits ===
=== '''Voir les commits''' ===
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
git log --oneline
git log --oneline
</syntaxhighlight>
</syntaxhighlight>
=== Voir les infos du dernier commit ===
=== '''Voir les infos du dernier commit''' ===
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
git log -1 HEAD
git log -1 HEAD
</syntaxhighlight>
</syntaxhighlight>


==Tag==
== '''Tag''' ==
Cherche le tag le plus récent dans l'historique du commit actuel.
Cherche le tag le plus récent dans l'historique du commit actuel.
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
Ligne 15 : Ligne 15 :
</syntaxhighlight>
</syntaxhighlight>


=== Création ===
=== '''Création''' ===
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
git tag -a v2.4.2 -m "Le message du commit"
git tag -a v2.4.2 -m "Le message du commit"
Ligne 21 : Ligne 21 :
</syntaxhighlight>
</syntaxhighlight>


=== Suppression ===
=== '''Suppression''' ===
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
git tag -d v2.4.1 # retire le tag dépôt local
git tag -d v2.4.1 # retire le tag dépôt local
Ligne 28 : Ligne 28 :
git push origin :refs/tags/v2.4.1 # retire le tag du repo distant
git push origin :refs/tags/v2.4.1 # retire le tag du repo distant
</syntaxhighlight>
</syntaxhighlight>
=== Voir ===
=== '''Voir''' ===
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
git show v2.4.1
git show v2.4.1
</syntaxhighlight>
</syntaxhighlight>
=== Renommer ===
=== '''Renommer''' ===
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
# conversion en tag annoté avec message
# conversion en tag annoté avec message
Ligne 41 : Ligne 41 :
</syntaxhighlight>
</syntaxhighlight>


===Renommer (Alternative moins risquée) ===
=== '''Renommer (Alternative moins risquée)''' ===
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
# 1. Mise à jour locale du tag
# 1. Mise à jour locale du tag
Ligne 53 : Ligne 53 :
</syntaxhighlight>
</syntaxhighlight>


== Dépot ==
== '''Dépot''' ==
=== Réinitialise votre branche locale à l'état de origin/master, supprimant toutes les modifications locales non validées ===
=== '''Réinitialise votre branche locale à l'état de origin/master, supprimant toutes les modifications locales non validées''' ===
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
git reset --hard origin/master
git reset --hard origin/master
</syntaxhighlight>
</syntaxhighlight>


=== Récupère et fusionne automatiquement une branche distante dans votre branche locale actuelle ===
=== '''Récupère et fusionne automatiquement une branche distante dans votre branche locale actuelle''' ===
<syntaxhighlight lang="bash" line copy>git pull</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git pull</syntaxhighlight>


=== Récupère les dernières modifications du dépôt distant sans les fusionner ===
=== '''Récupère les dernières modifications du dépôt distant sans les fusionner''' ===
<syntaxhighlight lang="bash" line copy>git fetch origin</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git fetch origin</syntaxhighlight>


=== Paramètre votre nouveau projet avec branche locale pour qu’elle suive la branche master ===
=== '''Paramètre votre nouveau projet avec branche locale pour qu’elle suive la branche master''' ===
<syntaxhighlight lang="bash" line copy>git clone</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git clone</syntaxhighlight>


=== Récupère les modifications ===
=== '''Récupère les modifications''' ===
<syntaxhighlight lang="bash" line copy>git push [nom-distant] [nom-de-branche]</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git push [nom-distant] [nom-de-branche]</syntaxhighlight>


=== Informations dépôt distant ===
=== '''Informations dépôt distant''' ===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
git remote show  
git remote show  
Ligne 77 : Ligne 77 :
</syntaxhighlight>
</syntaxhighlight>


=== Pour visualiser les serveurs distants ===
=== '''Pour visualiser les serveurs distants''' ===
au moins voir l’origine origin
au moins voir l’origine origin
nom par défaut que Git donne au serveur à partir duquel vous avez cloné  
nom par défaut que Git donne au serveur à partir duquel vous avez cloné  
Ligne 85 : Ligne 85 :
</syntaxhighlight>
</syntaxhighlight>


=== Définir l'url du dépot distant ===
=== '''Définir l'url du dépot distant''' ===
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
git remote set-url origin https://github.com/lecompte/leDepot  
git remote set-url origin https://github.com/lecompte/leDepot  
Ligne 94 : Ligne 94 :
</syntaxhighlight>
</syntaxhighlight>


=== Appliquer la branche locale en fonction de la distante ===
=== '''Appliquer la branche locale en fonction de la distante''' ===
<syntaxhighlight lang="bash" line copy>it branch --set-upstream-to=origin/master master</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>it branch --set-upstream-to=origin/master master</syntaxhighlight>


=== Raliser le suivi d'une branche distante ===
=== '''Raliser le suivi d'une branche distante''' ===
<syntaxhighlight lang="bash" line copy>git push --set-upstream origin master</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git push --set-upstream origin master</syntaxhighlight>


Ligne 104 : Ligne 104 :
https://git-scm.com/book/fr/v2/Les-bases-de-Git-Travailler-avec-des-dépôts-distants
https://git-scm.com/book/fr/v2/Les-bases-de-Git-Travailler-avec-des-dépôts-distants


== Branche ==
== '''Branche''' ==
=== Liste des branches courantes ===
=== '''Liste des branches courantes''' ===
<syntaxhighlight lang="bash" line copy>git branch</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git branch</syntaxhighlight>


=== Liste des derniers commits sur chaque branche ===
=== '''Liste des derniers commits sur chaque branche''' ===
<syntaxhighlight lang="bash" line copy>git branch -v</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git branch -v</syntaxhighlight>


=== Branches qui ont déjà été fusionnées dans votre branche courante ===
=== '''Branches qui ont déjà été fusionnées dans votre branche courante''' ===
<syntaxhighlight lang="bash" line copy>git branch --merged</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git branch --merged</syntaxhighlight>


=== Branches qui contiennent des travaux qui n’ont pas encore été fusionnés ===
=== '''Branches qui contiennent des travaux qui n’ont pas encore été fusionnés''' ===
<syntaxhighlight lang="bash" line copy>git branch --no-merged</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git branch --no-merged</syntaxhighlight>


=== Créer une branche ===
=== '''Créer une branche''' ===
<syntaxhighlight lang="bash" line copy>git branch -b une_branche</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git branch -b une_branche</syntaxhighlight>


=== Changer de branche ===
=== '''Changer de branche''' ===
<syntaxhighlight lang="bash" line copy>git checkout une_branche</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git checkout une_branche</syntaxhighlight>


=== Push sur une branche particulière ===
=== '''Push sur une branche particulière''' ===
<syntaxhighlight lang="bash" line copy>git push --set-upstream origin une_branche</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git push --set-upstream origin une_branche</syntaxhighlight>


=== Récupérer une branche qui n'existe pas en local
=== '''Récupérer une branche qui n'existe pas en local'''
<syntaxhighlight lang="bash" line copy>git checkout -b une_branche origin/une_branche</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git checkout -b une_branche origin/une_branche</syntaxhighlight>


=== Voir les modifs ===  
=== '''Voir les modifs''' ===  
<syntaxhighlight lang="bash" line copy>git status</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git status</syntaxhighlight>


=== Pousser les modifications ===  
=== '''Pousser les modifications''' ===  
<syntaxhighlight lang="bash" line>
<syntaxhighlight lang="bash" line>
git add .
git add .
Ligne 138 : Ligne 138 :
git push
git push
</syntaxhighlight>
</syntaxhighlight>
=== Merge ===
=== '''Merge''' ===
<syntaxhighlight lang="bash" line>
<syntaxhighlight lang="bash" line>
git checkout testing (pour changer de branche sur testing qui devient la courante)
git checkout testing (pour changer de branche sur testing qui devient la courante)
Ligne 145 : Ligne 145 :
</syntaxhighlight>
</syntaxhighlight>


=== Annuler un merge, etc ... ===
=== '''Annuler un merge, etc ...''' ===
<syntaxhighlight lang="bash" line copy>git reset --hard HEAD~;</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>git reset --hard HEAD~;</syntaxhighlight>


== Stash ==
== '''Stash''' ==
https://git-scm.com/docs/git-stash/fr
https://git-scm.com/docs/git-stash/fr


==Fenêtre graphique==
== '''Fenêtre graphique''' ==
<syntaxhighlight lang="bash" line copy>
<syntaxhighlight lang="bash" line copy>
gitk
gitk
</syntaxhighlight>
</syntaxhighlight>


== git config ==
== '''git config''' ==
=== This is Git's per-user configuration file. ===
=== '''This is Git's per-user configuration file''' ===
<syntaxhighlight lang="bash" line>
<syntaxhighlight lang="bash" line>
[user]
[user]