Site Tools


informatique:git

This is an old revision of the document!


git

Bloc note de commandes concernant git. Parce que concrètement, j'y vais un peu pif. Faudrait que je lise la doc, un jour.

 I have no idea what I'm doing

Ressources :

Connexion en SSH sous Windows

Tout est volé ici : https://www.it-connect.fr/comment-generer-une-paire-de-cles-ssh-et-lutiliser-avec-gitlab/

J'utilise le GitLab de Tedomum qui ne propose que l'authentification par SSH. OpenSSH est intégré sous Windows 10 et 11.

Générer une clef :

ssh-keygen -t ed25519
Enter file in which to save the key (C:\Users\utilisateur/.ssh/id_ed25519): C:\Users\utilisateur\.ssh\gittedo
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\utilisateur\.ssh\gittedo
Your public key has been saved in C:\Users\utilisateur\.ssh\gittedo.pub
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 :

cat C:\Users\utilisateur\.ssh\gittedo.pub | clip

Ajouter la clef privée :

ssh-add C:\Users\utilisateur\.ssh\gittedo

Si d'aventure ssh-add ne fonctionne pas, vérifier si le service est bien lancé soit par services.msc soit avec les commandes suivantes (voir ce fil sur Stackoverflow). Par défaut le service n'est pas lancé :

# 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 Key.

Tenter la connexion :

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 :

git config --global core.sshCommand "ssh -i C:/users/utilisateur/.ssh/gittedo"

Initialiser un projet

git config --global user.name "Username"
git config --global user.email mail@domaine.tld
cd dossier_du_projet
git init
git remote add origine git@forge.tedomum.net:utilisateur/projet.git

On vérifie

git remote -v

On change la branche

git branch -M main

Ajouter les fichiers au dépot

cd dossier_du_projet
git add [dossier ou fichier]
git commit -m "Commentaire"
git push

Pour le premier envoi j'ai fait :

git add .
git commit -m "Version initiale"
git push --set-upstream origin main

informatique/git.1731958776.txt.gz · Last modified: 2024/11/18 19:39 by yahiko