« Git Commandes » : différence entre les versions
Apparence
Aucun résumé des modifications |
|||
| Ligne 1 : | Ligne 1 : | ||
==Log== | ==Log== | ||
*Voir les commits | *Voir les commits | ||
< | <syntaxhighlight lang="bash" line copy> | ||
git log --oneline | git log --oneline | ||
</ | </syntaxhighlight> | ||
*Voir les infos du dernier commit | *Voir les infos du dernier commit | ||
< | <syntaxhighlight lang="bash" line copy> | ||
git log -1 HEAD | git log -1 HEAD | ||
</ | </syntaxhighlight> | ||
==Tag== | ==Tag== | ||
| Ligne 55 : | Ligne 55 : | ||
== Dépot == | == Dépot == | ||
=== 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> | ||
=== Récupère les dernières modifications du dépôt distant sans les fusionner === | |||
<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> | ||
=== Récupère les modifications === | === Récupère les modifications === | ||
< | <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"> | ||
git remote show | git remote show | ||
git remote show [nom-distant] | git remote show [nom-distant] | ||
</ | </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é | ||
< | <syntaxhighlight lang="bash"> | ||
git remote | git remote | ||
git remote -v | git remote -v | ||
</ | </syntaxhighlight> | ||
=== Définir l'url du dépot distant === | === Définir l'url du dépot distant === | ||
< | <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 | ||
</ | </syntaxhighlight> | ||
ou pour ssh avec une key pub à ajouter | ou pour ssh avec une key pub à ajouter | ||
< | <syntaxhighlight lang="bash" line copy> | ||
git remote add origin git@github.com:lecompte/leDepot.git | git remote add origin git@github.com:lecompte/leDepot.git | ||
</ | </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> | ||
=== 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> | ||
--- | --- | ||
| Ligne 98 : | Ligne 101 : | ||
== Branche == | == Branche == | ||
=== Liste des branches courantes === | === Liste des branches courantes === | ||
< | <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> | ||
=== 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> | ||
=== 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> | ||
=== Créer une branche === | === Créer une branche === | ||
< | <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> | ||
=== 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> | ||
=== 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> | ||
=== Voir les modifs === | === Voir les modifs === | ||
< | <syntaxhighlight lang="bash" line copy>git status</syntaxhighlight> | ||
=== Pousser les modifications === | === Pousser les modifications === | ||
<syntaxhighlight lang="bash" line> | |||
git add . | git add . | ||
git commit =m "le message de commit" | git commit =m "le message de commit" | ||
git push | git push | ||
</syntaxhighlight> | |||
=== Merge === | === Merge === | ||
< | <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) | ||
git merge master ( permet d'avancer la branche courante en incorporant le travail d'une autre branche : celle de master) | 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) | git push (transférer les commits du dépôt local vers un dépôt distant) | ||
</ | </syntaxhighlight> | ||
=== Annuler un merge, etc ... === | === Annuler un merge, etc ... === | ||
< | <syntaxhighlight lang="bash" line copy>git reset --hard HEAD~;</syntaxhighlight> | ||
== Stash == | == Stash == | ||
| Ligne 143 : | Ligne 147 : | ||
==Fenêtre graphique== | ==Fenêtre graphique== | ||
< | <syntaxhighlight lang="bash" line copy> | ||
gitk | gitk | ||
</ | </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> | ||
[user] | [user] | ||
name = Doo John | name = Doo John | ||
| Ligne 155 : | Ligne 159 : | ||
[core] | [core] | ||
autocrlf = true | autocrlf = true | ||
</ | </syntaxhighlight> | ||
[[Catégorie:Git]] | [[Catégorie:Git]] | ||
Version du 12 juin 2025 à 22:15
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é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