This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
informatique:git [2023/06/09 10:13] – yahiko | informatique:git [2024/12/08 16:04] (current) – yahiko | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | J'ai commencé à utiliser git il y a peu pour stocker et gérer les scripts que je réalise pour mon activité pro. Je vais mettre ici les commandes usuelles que j'ai utilisé. | + | |
- | https:// | + | Bloc note de commandes concernant Git. Parce que concrètement, |
- | ===== S' | + | {{ : |
- | < | + | |
- | git config | + | |
- | git config --global user.email " | + | |
- | git config --global --list | + | |
- | </ | + | Ressources : |
- | ===== Initialiser | + | * https:// |
- | <codedoc> | + | * https:// |
- | cd dossier_repo | + | * https:// |
+ | * https:// | ||
+ | |||
+ | ===== Connexion en SSH sous Windows ===== | ||
+ | Tout est volé ici : https:// | ||
+ | |||
+ | J' | ||
+ | |||
+ | Générer une clef : | ||
+ | <code bash> | ||
+ | ssh-keygen -t ed25519 | ||
+ | Enter file in which to save the key (C: | ||
+ | Enter passphrase (empty for no passphrase): | ||
+ | Enter same passphrase again: | ||
+ | Your identification has been saved in C: | ||
+ | Your public key has been saved in C: | ||
+ | The key fingerprint is: | ||
+ | SHA256: | ||
+ | The key's randomart image is: | ||
+ | +--[ED25519 256]--+ | ||
+ | | ..E .o++. o .| | ||
+ | | . .. . oo+= o B | | ||
+ | | . . o+.B *.=| | ||
+ | | o +.B + =o| | ||
+ | | S B . . .| | ||
+ | | + + = . . | | ||
+ | | + + . o | | ||
+ | | . . o o | | ||
+ | | . . | | ||
+ | +----[SHA256]-----+ | ||
+ | </ | ||
+ | |||
+ | On met la clef dans le presse papier : | ||
+ | <code powershell> | ||
+ | cat C: | ||
+ | </ | ||
+ | |||
+ | Ajouter la clef privée : | ||
+ | <code powershell> | ||
+ | ssh-add C: | ||
+ | </ | ||
+ | |||
+ | Si d' | ||
+ | <code powershell> | ||
+ | # Active le service | ||
+ | Get-Service ssh-agent | Set-Service -StartupType Automatic | ||
+ | # Démarre le service | ||
+ | Start-Service ssh-agent | ||
+ | # Vérifie que le service est lancé | ||
+ | Get-Service ssh-agent | ||
+ | </ | ||
+ | |||
+ | Sur GitLab, aller dans Preferences > SSH Keys > Add new key et coller la clef dans le champ '' | ||
+ | |||
+ | Tenter la connexion : | ||
+ | |||
+ | <code bash> | ||
+ | ssh -T git@forge.tedomum.net | ||
+ | Welcome to GitLab, @yahiko! | ||
+ | </ | ||
+ | |||
+ | Pour que cela fonctionne avec git, il faut aussi indiquer à git la clef privée : | ||
+ | <code bash> | ||
+ | git config --global core.sshCommand "ssh -i C:/ | ||
+ | </ | ||
+ | |||
+ | ===== Initialiser | ||
+ | <code bash> | ||
+ | git config --global user.name " | ||
+ | git config --global user.email mail@domaine.tld | ||
+ | cd dossier_du_projet | ||
git init | git init | ||
- | git remote add origin | + | git remote add origin |
+ | </code> | ||
+ | |||
+ | On vérifie | ||
+ | <code bash> | ||
git remote -v | git remote -v | ||
+ | </ | ||
+ | |||
+ | On change la branche | ||
+ | <code bash> | ||
git branch -M main | git branch -M main | ||
- | git push -uf origin main | + | </code> |
- | </codedoc> | + | |
- | ===== Ajouter | + | ===== Ajouter |
- | <codedoc> | + | <code bash> |
- | cd dossier_repo | + | cd dossier_du_projet |
git add [dossier ou fichier] | git add [dossier ou fichier] | ||
git commit -m " | git commit -m " | ||
git push | git push | ||
- | </codedoc> | + | </code> |
+ | |||
+ | Pour le premier envoi j'ai fait : | ||
+ | <code bash> | ||
+ | git add . | ||
+ | git commit -m " | ||
+ | git push --set-upstream origin main | ||
+ | </ | ||
+ | |||
+ | Lors du premier envoi : | ||
+ | <code bash> | ||
+ | git push --set-upstream git@forge.tedomum.net: | ||
+ | </ | ||
+ | |||
+ | Si problème lors du push : | ||
+ | <code bash> | ||
+ | git pull --rebase origin main | ||
+ | git push --set-upstream origin main | ||
+ | </ | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ===== Git pull ===== | ||
+ | |||
+ | Pour récupérer le projet sur un autre machine | ||
+ | |||
+ | <code bash> | ||
+ | mkdir dossier && cd dossier | ||
+ | git init | ||
+ | git pull git@forge.tedomum.net: | ||
+ | </code> |