« Git Commandes » : différence entre les versions

Aucun résumé des modifications
Ligne 1 : Ligne 1 :
==Log==
==Log==
*Voir les commits
*Voir les commits
<pre>
<syntaxhighlight lang="bash" line copy>
git log --oneline
git log --oneline
</pre>
</syntaxhighlight>
*Voir les infos du dernier commit
*Voir les infos du dernier commit
<pre>
<syntaxhighlight lang="bash" line copy>
git log -1 HEAD
git log -1 HEAD
</pre>
</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 ===
<pre>git pull</pre>
<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 ===
<pre>git clone </pre>
<syntaxhighlight lang="bash" line copy>git clone</syntaxhighlight>


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


=== Informations dépôt distant ===
=== Informations dépôt distant ===
<pre>
<syntaxhighlight lang="bash">
git remote show  
git remote show  
git remote show [nom-distant]
git remote show [nom-distant]
</pre>
</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é  
<pre>
<syntaxhighlight lang="bash">
git remote  
git remote  
git remote -v
git remote -v
</pre>
</syntaxhighlight>


=== Définir l'url du dépot distant ===
=== Définir l'url du dépot distant ===
<pre>
<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  
</pre>
</syntaxhighlight>
ou pour ssh avec une key pub à ajouter
ou pour ssh avec une key pub à ajouter
<pre>
<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
</pre>
</syntaxhighlight>


=== Appliquer la branche locale en fonction de la distante ===
=== Appliquer la branche locale en fonction de la distante ===
<pre>git branch --set-upstream-to=origin/master master</pre>
<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 ===
<pre>git push --set-upstream origin master </pre>
<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 ===
<pre>git branch</pre>
<syntaxhighlight lang="bash" line copy>git branch</syntaxhighlight>


=== Liste des derniers commits sur chaque branche ===
=== Liste des derniers commits sur chaque branche ===
<pre>git branch -v</pre>
<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  ===
<pre>git branch --merged</pre>
<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 ===
<pre>git branch --no-merged</pre>
<syntaxhighlight lang="bash" line copy>git branch --no-merged</syntaxhighlight>


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


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


=== Push sur une branche particulière ===
=== Push sur une branche particulière ===
<pre>git push --set-upstream origin une_branche</pre>
<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
<pre>git checkout -b une_branche origin/une_branche</pre>
<syntaxhighlight lang="bash" line copy>git checkout -b une_branche origin/une_branche</syntaxhighlight>


=== Voir les modifs ===  
=== Voir les modifs ===  
<pre>git status</pre>
<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 ===
<pre>
<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)
</pre>
</syntaxhighlight>


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


== Stash ==
== Stash ==
Ligne 143 : Ligne 147 :


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


== git config ==
== git config ==
=== This is Git's per-user configuration file. ===
=== This is Git's per-user configuration file. ===
<pre>
<syntaxhighlight lang="bash" line>
[user]
[user]
name = Doo John
name = Doo John
Ligne 155 : Ligne 159 :
[core]
[core]
autocrlf = true
autocrlf = true
</pre>
</syntaxhighlight>


[[Catégorie:Git]]
[[Catégorie:Git]]