« Git Commandes » : différence entre les versions
Apparence
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] | ||
Version du 12 juin 2025 à 22:22
Log
Voir les commits
git log --oneline
Voir les infos du dernier commit
git log -1 HEAD
Tag
Cherche le tag le plus récent dans l'historique du commit actuel.
git describe --tags
Création
git tag -a v2.4.2 -m "Le message du commit"
git push --tags
Suppression
git tag -d v2.4.1 # retire le tag dépôt local
git push origin :refs/tags/v2.4.1 # retire le tag du repo distant
Voir
git show v2.4.1
Renommer
# conversion en tag annoté avec message
git tag v1.0.2 v1.0.2^{} -f -m "message détaillé"
# Efface tous les tags distants non présents localement.
# Peut écraser des tags créés par d'autres sans garde-fou.
git push -f origin --tags
Renommer (Alternative moins risquée)
# 1. Mise à jour locale du tag
git tag -fa v1.0.2 -m "Nouveau message"
# 2. Suppression du tag distant
git push origin :v1.0.2
# 3. Push du nouveau tag
git push origin v1.0.2
Dépot
Réinitialise votre branche locale à l'état de origin/master, supprimant toutes les modifications locales non validées
git reset --hard origin/master
Récupère et fusionne automatiquement une branche distante dans votre branche locale actuelle
git pull
Récupère les dernières modifications du dépôt distant sans les fusionner
git fetch origin
Paramètre votre nouveau projet avec branche locale pour qu’elle suive la branche master
git clone
Récupère les modifications
git push [nom-distant] [nom-de-branche]
Informations dépôt distant
git remote show
git remote show [nom-distant]
Pour visualiser les serveurs distants
au moins voir l’origine origin nom par défaut que Git donne au serveur à partir duquel vous avez cloné
git remote
git remote -v
Définir l'url du dépot distant
git remote set-url origin https://github.com/lecompte/leDepot
ou pour ssh avec une key pub à ajouter
git remote add origin git@github.com:lecompte/leDepot.git
Appliquer la branche locale en fonction de la distante
it branch --set-upstream-to=origin/master master
Raliser le suivi d'une branche distante
git push --set-upstream origin master
--- source: https://git-scm.com/book/fr/v2/Les-bases-de-Git-Travailler-avec-des-dépôts-distants
Branche
Liste des branches courantes
git branch
Liste des derniers commits sur chaque branche
git branch -v
Branches qui ont déjà été fusionnées dans votre branche courante
git branch --merged
Branches qui contiennent des travaux qui n’ont pas encore été fusionnés
git branch --no-merged
Créer une branche
git branch -b une_branche
Changer de branche
git checkout une_branche
Push sur une branche particulière
git push --set-upstream origin une_branche
=== Récupérer une branche qui n'existe pas en local
git checkout -b une_branche origin/une_branche
Voir les modifs
git status
Pousser les modifications
git add .
git commit =m "le message de commit"
git push
Merge
git checkout testing (pour changer de branche sur testing qui devient la courante)
git merge master ( permet d'avancer la branche courante en incorporant le travail d'une autre branche : celle de master)
git push (transférer les commits du dépôt local vers un dépôt distant)
Annuler un merge, etc ...
git reset --hard HEAD~;
Stash
https://git-scm.com/docs/git-stash/fr
Fenêtre graphique
gitk
git config
This is Git's per-user configuration file
[user]
name = Doo John
email = jhon.doo@github.fr
[core]
autocrlf = true