Mettre à jour workspace directement depuis dépôt distant (méthode brusque) : git pull
** Méthode douce :**
Cumul ⇒ gut pull –rebase
Mettre à jour dépôt local et workspace si d'autres commits on été poussé dans le repo distant et que du travail en workspace n'a pas été indexé
Mettre à jour dépôt local et workspace sur une branche de dev alors que d'autres commits ont été poussé sur la branche master depuis sur le repo distant
** Changer url d'un dépôt distant :**
**Mise à jour dépot local après avoir effecuté modifs dans le workspace : ** git add .
⇒ indexe toutes les modifs locales dans l'index (modifs de fichier, ajout, déplacement de fichiers, création dossier….)
Mise à jour workspace en placant HEAD au même niveau qu'un tag :
git checkout TAG (par ex v3.1.1)
Renommer une branche dans le workspace :
git branch -m BRANCH
Supprimer du repo local les branches distantes qui n'existent plus :
git remote prune origin
Supprimer une branche dans le workspace :
git branch -d BRANCH
Ajout selectif des modifications
Faire un git add -p pour choisir les modification qu'on souhaite ajouter au prochain commit.
Options possibles pour chaque ajout :
Stage this hunk [y,n,a,d,/,j,J,g,e,?]? ? y - stage this hunk n - do not stage this hunk a - stage this and all the remaining hunks in the file d - do not stage this hunk nor any of the remaining hunks in the file g - select a hunk to go to / - search for a hunk matching the given regex j - leave this hunk undecided, see next undecided hunk J - leave this hunk undecided, see next hunk k - leave this hunk undecided, see previous undecided hunk K - leave this hunk undecided, see previous hunk s - split the current hunk into smaller hunks e - manually edit the current hunk ? - print help
Source : https://git-scm.com/book/it/v2/Git-Tools-Interactive-Staging#r_interactive_staging
⇒ Possibilité d'effectuer merge en cli avant le push
PRIVILÉGIER de passer par Gitlab. Aller dans le projet ⇒ Merge Request ⇒ New Merge request
⇒ Historiques des commits (git lg amélioré)
lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)-%an%C(reset)%C(bold yellow)%d%C(reset)' --all
git cherry-pick ID_COMMIT
git diff --fichier_à_modifier > nomdupatch.patch
git apply /chemin/depôt/source/nomdupatch.patch
git commit --amend
git tag version-tag
git commit --amend --no-edit
git commit --allow-empty -m "Faux commit"
git config --list