« Git Commandes » : différence entre les versions
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]] | ||