Git : l'historique d'un projet (école d'ingénieur) · Chapitre 6 · Exercice de TD
Lire la configuration de suivi
Les dépôts distants · niveau 1 (application)
Énoncé
Voici la configuration de suivi du portable d'Ada après son premier envoi :
$ git config --get-regexp '^(remote|branch)\.'
remote.origin.url /srv/librairie.git
remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
branch.main.remote origin
branch.main.merge refs/heads/main
Sur la branche main, que font git fetch, git pull et git push sans argument ? Sur une branche essai créée localement et jamais envoyée, que fait git push ?
Corrigé
Sur main, git fetch récupère d'origin (branch.main.remote) toutes ses branches, recopiées en origin/* (remote.origin.fetch). git pull fait ce fetch, puis intègre la branche refs/heads/main du distant (branch.main.merge), c'est-à-dire origin/main. git push envoie main vers la branche main d'origin. Sur une branche essai sans amont, git push refuse et donne la commande à taper :
$ git push
fatal: The current branch essai has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin essai
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
Exercices semblables
- Ce que contient un clone corrigé
- Un pull qui fusionne corrigé
- Supprimer une branche distante corrigé
- SSH ou HTTPS corrigé
- Pousser vers un dépôt non nu corrigé