Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
|
prog:git:commandes [12/09/2022 16:35] thierry créée |
prog:git:commandes [01/10/2022 11:21] (Version actuelle) thierry [Basculer sur une autre branche] |
||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ====== Commandes GIT ====== | ====== Commandes GIT ====== | ||
| + | ===== Commandes ===== | ||
| + | * git add %NomDuFichier% (ou *) | ||
| + | * git commit (-m "%Message%") | ||
| + | * git log : affiche les modifications | ||
| + | * git checkout %CommitId% (%CommitId% est visible dans git log) | ||
| + | * git checkout master (-f) reviens au dernier commit | ||
| + | * git checkout %NomBranche% : basculement sur la branche %NomBranche% | ||
| + | * git branch : affiche les branches | ||
| + | * git branch %NomBranche% : crée une nouvelle branche | ||
| + | * git switch %BranchName% : basculement sur la branche %BrancheName% | ||
| + | * git merge %BrancheName% : fusion de la branche active avec la branche %BrancheName% | ||
| + | |||
| + | ===== Utilisation courante ===== | ||
| + | ==== Savoir dans quelle branche on se trouve ==== | ||
| + | commande ''git branch'' affiche | ||
| + | <code bash> | ||
| + | J:\webprojects>git branch | ||
| + | * installation-sécurité | ||
| + | master | ||
| + | </code> | ||
| + | La branche ou l'on se trouve actuellement est précédée d'un ''*'' | ||
| + | ==== Ajouter une branche ==== | ||
| + | commande ''git branch %NomDeLaBranche%'' | ||
| + | <code bash> | ||
| + | J:\webprojects>git branch test | ||
| + | |||
| + | J:\webprojects>git branch | ||
| + | * installation-sécurité | ||
| + | master | ||
| + | test | ||
| + | </code> | ||
| + | |||
| + | ==== Basculer sur une autre branche ==== | ||
| + | commande ''git checkout %NomDeLaBranche%'' | ||
| + | <code bash> | ||
| + | J:\webprojects>git checkout test | ||
| + | Switched to branch 'test' | ||
| + | |||
| + | J:\webprojects>git branch | ||
| + | installation-sécurité | ||
| + | master | ||
| + | * test | ||
| + | </code> | ||
| + | |||
| + | ==== Fusionner deux branche ==== | ||
| + | * On se positionne sur la branche principale : ''git checkout master'' | ||
| + | * On merge les branches avec ''git merge test'' | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| ====== Sources & Ressources ====== | ====== Sources & Ressources ====== | ||
| * [[https://www.youtube.com/watch?v=225wkShIcc8]] | * [[https://www.youtube.com/watch?v=225wkShIcc8]] | ||