- 7.1 Sélection des versions
- 7.2 Indexation interactive
- 7.3 Remisage et nettoyage
- 7.4 Signer votre travail
- 7.5 Recherche
- 7.6 Réécrire l’historique
- 7.7 Reset démystifié
- 7.8 Fusion avancée
- 7.9 Rerere
- 7.10 Déboguer avec Git
- 7.11 Sous-modules
- 7.12 Empaquetage (bundling)
- 7.13 Replace
- 7.14 Stockage des identifiants
- 7.15 Résumé
A3. Git Commands
- A3.1 Installation et configuration
- A3.2 Obtention et création des projets
- A3.3 Capture d’instantané basique
- A3.4 Création de branches et fusion
- A3.5 Partage et mise à jour de projets
- A3.6 Inspection et comparaison
- A3.7 Débogage
- A3.8 Patchs
- A3.9 Courriel
- A3.10 Systèmes externes
- A3.11 Administration
- A3.12 Commandes de plomberie
A3.5 Git Commands - Sharing and Updating Projects
Sharing and Updating Projects
There are not very many commands in Git that access the network, nearly all of the commands operate on the local database. When you are ready to share your work or pull changes from elsewhere, there are a handful of commands that deal with remote repositories.
git fetch command communicates with a remote repository and fetches down all the information that is in that repository that is not in your current one and stores it in your local database.
We also use it in several of the examples in “Contribution à un projet”.
git pull command is basically a combination of the
git fetch and
git merge commands, where Git will fetch from the remote you specify and then immediately try to merge it into the branch you’re on.
We also see how to use it to help with rebasing difficulties in “Rebaser quand vous rebasez”.
We show how to use it with a URL to pull in changes in a one-off fashion in “Vérification des branches distantes”.
Finally, we very quickly mention that you can use the
--verify-signatures option to it in order to verify that commits you are pulling have been GPG signed in “Signer des commits”.
git push command is used to communicate with another repository, calculate what your local database has that the remote one does not, and then pushes the difference into the other repository. It requires write access to the other repository and so normally is authenticated somehow.
We first look at the
git push command in “Pousser son travail sur un dépôt distant”. Here we cover the basics of pushing a branch to a remote repository. In “Pousser les branches” we go a little deeper into pushing specific branches and in “Suivre les branches” we see how to set up tracking branches to automatically push to. In “Suppression de branches distantes” we use the
--delete flag to delete a branch on the server with
Throughout “Contribution à un projet” we see several examples of using
git push to share work on branches through multiple remotes.
We see how to use it to share tags that you have made with the
--tags option in “Partager les étiquettes”.
In ??? we use it in a slightly less common way to share references for commit notes — references that sit outside of the normal refs namespace.
In “Publier les modifications dans un sous-module” we use the
--recurse-submodules option to check that all of our submodules work has been published before pushing the superproject, which can be really helpful when using submodules.
In “Autres crochets côté client” we talk briefly about the
pre-push hook, which is a script we can setup to run before a push completes to verify that it should be allowed to push.
Finally, in “Pousser des refspecs” we look at pushing with a full refspec instead of the general shortcuts that are normally used. This can help you be very specific about what work you wish to share.
git remote command is a management tool for your record of remote repositories. It allows you to save long URLs as short handles, such as “origin” so you don’t have to type them out all the time. You can have several of these and the
git remote command is used to add, change and delete them.
This command is covered in detail in “Travailler avec des dépôts distants”, including listing, adding, removing and renaming them.
It is used in nearly every subsequent chapter in the book too, but always in the standard
git remote add <name> <url> format.
git archive command is used to create an archive file of a specific snapshot of the project.
git archive to create a tarball of a project for sharing in “Préparation d’une publication”.
git submodule command is used to manage external repositories within a normal repositories. This could be for libraries or other types of shared resources. The
submodule command has several sub-commands (
sync, etc) for managing these resources.
This command is only mentioned and entirely covered in “Sous-modules”.