projtec:git
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
projtec:git [2019/04/03 07:51] – niko | projtec:git [2024/03/18 15:06] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 25: | Line 25: | ||
# mail / user name | # mail / user name | ||
git config --global user.name " | git config --global user.name " | ||
- | git config --global user.mail aurelien.esnard@u-bordeaux.fr | + | git config --global user.email aurelien.esnard@u-bordeaux.fr |
# editeur de texte | # editeur de texte | ||
git config --global core.editor emacs | git config --global core.editor emacs | ||
Line 203: | Line 203: | ||
Nous sommes encore dans la branche //master// comme l' | Nous sommes encore dans la branche //master// comme l' | ||
<code bash> | <code bash> | ||
- | git checkout | + | git switch |
git branch | git branch | ||
* hotfix | * hotfix | ||
Line 235: | Line 235: | ||
</ | </ | ||
- | Pour propager cette modification vers la branche //master//, il va falloir repasser dans la branche // | + | Pour propager cette modification vers la branche //master//, il va falloir repasser dans la branche //master//, faire quelques modifs sur master puis effectuer un //merge//. |
<code bash> | <code bash> | ||
- | git checkout | + | git switch |
+ | date >> date2.txt | ||
+ | git add date2.txt | ||
+ | git commit -m " | ||
git merge hotfix | git merge hotfix | ||
</ | </ | ||
Line 260: | Line 263: | ||
git log --graph --oneline | git log --graph --oneline | ||
* c38c81a (HEAD -> hotfix) deux dates dans hotfix | * c38c81a (HEAD -> hotfix) deux dates dans hotfix | ||
+ | * c908469 bla bla | ||
+ | * d144ffa autre bla bla | ||
(...) | (...) | ||
- | git checkout | + | git switch |
git push --set-upstream origin hotfix | git push --set-upstream origin hotfix | ||
git log --graph --oneline | git log --graph --oneline | ||
* c38c81a (HEAD -> hotfix, origin/ | * c38c81a (HEAD -> hotfix, origin/ | ||
+ | * c908469 bla bla | ||
+ | * d144ffa autre bla bla | ||
(...) | (...) | ||
</ | </ | ||
- | La encore on se synchronisera avec la branche distance à l'aide des commandes push/pull. | + | La encore on se synchronisera avec la branche distance à l'aide des commandes push/pull: |
- | Pour voir toutes les branches | + | <code bash> |
+ | date >> date.txt | ||
+ | git add date.txt | ||
+ | git commit -m "mise à jour de la date" | ||
+ | git log --graph --oneline | ||
+ | * 68b1978 | ||
+ | * c38c81a (origin/ | ||
+ | (...) | ||
+ | git push | ||
+ | git log --graph --oneline | ||
+ | * 68b1978 (HEAD -> hotfix, origin/ | ||
+ | * c38c81a deux dates dans hotfix | ||
+ | (...) | ||
+ | </ | ||
+ | |||
+ | Pour voir toutes les branches (locales et distantes) : | ||
+ | <code bash> | ||
git fetch -p | git fetch -p | ||
git branch -a | git branch -a | ||
+ | </ | ||
| | ||
__Nota Bene__ : le //fetch// permet de mettre à jour son cache local et éventuellement (option -p) d' | __Nota Bene__ : le //fetch// permet de mettre à jour son cache local et éventuellement (option -p) d' | ||
| | ||
- | Pour récupérer une branche distante et la suivre via une branche locale : | ||
- | | + | Puis pour supprimer la branche locale, il faut faire ceci : |
+ | <code bash> | ||
+ | | ||
+ | </code> | ||
- | Puis pour supprimer la branche distante (enfin presque...), | ||
+ | Puis pour supprimer la branche distante (enfin presque...), | ||
+ | <code bash> | ||
git push origin --delete mybranch | git push origin --delete mybranch | ||
- | + | </code> | |
- | Expliquer le //rebase// simple : | + | |
- | | + | Pour récupérer une branche distante et la suivre via une branche locale : |
- | git rebase master | + | <code bash> |
- | git checkout | + | |
- | git merge mybranch | + | </ |
+ | |||
+ | Considérons le cas suivant... Expliquer ensuite le //rebase// simple : | ||
+ | |||
+ | <code bash> | ||
+ | git switch | ||
+ | git rebase master | ||
+ | git switch | ||
+ | git merge mybranch | ||
git branch -d mybranch | git branch -d mybranch | ||
+ | </ | ||
Pour aller plus loin : | Pour aller plus loin : | ||
Line 416: | Line 451: | ||
L' | L' | ||
+ | |||
+ | === Suppression d'une Branche Distante ==== | ||
+ | |||
+ | Pour supprimer une branche locale sur votre ordinateur, la commande est la suivante : | ||
+ | |||
+ | $ git branch -d [nom_de_la_branche] | ||
+ | |||
+ | Ou bien : | ||
+ | |||
+ | $ git branch -D [nom_de_la_branche] | ||
+ | |||
+ | Pour supprimer la branche située sur le dépôt distant (syntaxe récente) : | ||
+ | |||
+ | $ git push origin --delete [nom_de_la_branche] | ||
+ | |||
+ | Pour mettre à jour les changements sur un autre ordinateur, il faut faire : | ||
+ | |||
+ | $ git fetch --all -prune | ||
+ | |||
+ | => https:// | ||
+ | ==== Suppression de Commit Fautifs sur le dépôt distant ==== | ||
+ | |||
+ | Revenir à l' | ||
+ | |||
+ | $ git reset --hard <commit hash> | ||
+ | |||
+ | Forcer cet état comme le dernier état du dépôt : | ||
+ | |||
+ | $ git push --force origin master | ||
+ | | ||
+ | Attention : Ces commandes sont susceptibles d' | ||
==== Savane ==== | ==== Savane ==== | ||
Line 434: | Line 500: | ||
==== A Lire ==== | ==== A Lire ==== | ||
+ | * https:// | ||
+ | * https:// | ||
* https:// | * https:// | ||
* http:// | * http:// | ||
Line 440: | Line 508: | ||
* https:// | * https:// | ||
* https:// | * https:// | ||
+ | * https:// |
projtec/git.1554277906.txt.gz · Last modified: 2024/03/18 15:05 (external edit)