Files
old-docs/sheatsheet/git.rst
2023-12-30 22:30:42 +01:00

123 lines
2.7 KiB
ReStructuredText

..
Copyright (C) 2023 Jeremie Salvi.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
Git Sheatsheet
==============
Initialisation d'un dépot
-------------------------
``git init (-b master branch name) (--bare pour un dépot distant sans work area)``
Clonage, synchronisation et update
----------------------------------
Clonage
``git clone <url>``
Pousser un dépot local sur un dépot distant qui vient d'être initalisé
``git remote add origin ssh://user@git-server/path/to/myrepo.git``
``git push --set-upstream origin master``
Synchronisation
``git fetch``
``git pull <remote(origin)> <branch(master)>``
Update
``git push <remote(origin)> <branch(master)>``
Versionning
-----------
Pour versionner, il faut utiliser git tag.
``git tag (-a vx.x.x-rcx) (-m "comment")``
Pour synchroniser le tag avec le dépot distant,
il faut un push spécifique pour la version :
``git push branch(origin) tag(vx.x.x-rcx)``
pour supprimer un tag
``git tag -d vx.x.x``
Et pour le supprimer sur le dépot distant
``git push --delete origin v1.1.0``
Commit
------
``git commit (-a all modified files) (-m message)``
Navigation
----------
``git ls-tree``
Merge des commit
----------------
Git créer un snapshot à chaque commit, cela améliore les
performances par rapport à d'autres systèmes de versionning,
mais cela prend vite aussi beaucoup de place.
Pour alléger cela, on peut merger une suite de commit en
un seul avant de push sur le serveur. On utilise la commande suivante :
``git rebase -i(--interactive) <merge-after-this-commit>``
et on remplace les derniers "pick" dans le shell interactif par squash.
.. code-block:: bash
:linenos:
pick 309769c updating .Xressources configuration
squash 39a45ab updating .Xressources configuration
squash 76f1543 updating .Xressources configuration
example :
``git rebase -i HEAD~5``
``git rebase -i 6919b24b1285f00b59eae416faf7ccfba0987843``
``git rebase -i origin/master`` (pour push un seul commit depuis la dernièrebase
synchronisation avec la branche master de notre dépot distant)
Configuration générale
----------------------
``git config --global init.defaultBranch master``
``git config --global user.email "you@example.com"``
``git config --global user.name "Your Name"``
Workflow
--------
``git pull``
aussi souvent que nmécessaire
- ``git add``
- ``git commit``
``git rebase -i origin/master``
``git push``