public:git

Ceci est une ancienne révision du document !


Git (GitHub / GitLab / Gitea)

Installer Oh-My-Bash à l’aide de curl bash -c “$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)”

Après l’installation : source ~/.bashrc

Modifier thème de Bash dans ~/.bashrc
https://github.com/ohmybash/oh-my-bash/wiki/Themes

nano ~/.bashrc

Modifier la ligne

OSH_THEME="font"

en

OSH_THEME="absimple"

Recharger le .bashrc

source ~/.bashrc



Configurer un projet GIT

# configuration locale d'un projet

git config user.name Matt
git config user.email [email protected]

# configuration globale de git

$ git config --global user.name Matt
$ git config --global user.email [email protected]

# lire la configuration actuelle

git config --list

# Pour facilité la vision des logs

git config --global pager.log false

Installer git

dnf install git # redhat/oracle os
apt install git # debian os

Voir la version git

git --version

Aide git

git --help
man git
man git [cmd]

Clonage depot git

git clone http://url/du/projet

Initialiser un projet git

mkdir monprojet
git init monprojet

Voir le statut du projet git

git status

Ajouter un fichier/dossier au projet git

git add mondossier
git add monfichier
git add .

Versionner un dossier avec message

git commit
git commit -m "message"

Voir les logs

git log
git log --oneline
git log --oneline --name-status

Initier un projet git

mkdir mon projet
cd monprojet/
git init
touch README.md
git add .
git commit -m "Init new project"
git push origin master

Démarrer un projet depuis un depot git

git clone http://url/monprojet.git
cd monprojet

Créér une branche

git branch develop

Supprimer une branche

git branch -d nom-de-branche

Changer de branche

git checkout develop

Créér et changer de branche

git checkout -b develop

Voir les branches

git branch

Fusionner deux branches

# se positionner sur la branche où il va y'avoir la fusion

git checkout master

# faire la fusion de la branch vers celle ou on est positionné

git merge develop

Créér des sous branches dans develop, puis les fusionner dans develop, puis les fusionner dans master # depuis develop

git checkout -b ansible
touch test.yaml
git add .
git commit -m "add config"

# revenir dans la branche supérieur (develop)

git checkout develop
git merge ansible

# puis fusionner les divers changements dans master

Donner des numéros de versions à ses commits Créér un tag

git tag v1.0

voir un tag

git tag
git show v0.1

Créér un tag à un commit antérieur # regarder les logs

git log --oneline

# tagger un hash

git tag v0.1 70ae760

# voir un tag

git show v0.1

Création de la clé SSH

ssh-keygen -o -a 100 -t ed25519 -C "VM_TP4_Module9"

Création d'un alias SSH

$ vi ~/.ssh/config
Host gitlab
  HostName gitlab.example.com
  User git
  Port 22
  IdentityFile /home/elisa/.ssh/id_ed25519

Maintenant l'alias gitlab est créer

Vérifier type connexion http ou ssh pour le push

git remote -v

La toute premiere fois pour la branche ou branche qui n'existe pas encore

git push --set-upstream origin nom-de-branche

Ensuite vous pouvez simplement utiliser

git push

Télécharger les modifications

git pull nom-de-branche

Rollback d'une modification non encore commitée

git checkout -- readme

La Commande GIT RESET (ne garde pas l'historique des commits, supprime le commit)

rollback au commit précédent en gardant les modifications de l'espace de travail

git reset --soft HEAD~1

rollback au commit précédent sans garder les modifications de l'espace de travail

git reset --hard HEAD~1

commande git revert (garde l'historique des commits,créé un nouveau commit en inversant les changements apportés par un commit)

git revert [hash commit1] [hash commit 2] ...



Command line instructions You can also upload existing files from your computer using the instructions below.

git config --global user.name "user16-eni"
git config --global user.email "[email protected]"
git clone [email protected]:user16-eni/user16-project.git
cd user16-project
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
git push -u origin main
Push an existing folder
git init --initial-branch=main
git remote add origin [email protected]:user16-eni/user16-project.git
git add .
git commit -m "Initial commit"
git push -u origin main
cd existing_repo
git remote rename origin old-origin
git remote add origin [email protected]:user16-eni/user16-project.git
git push -u origin --all
git push -u origin --tags
  • public/git.1729684519.txt.gz
  • Dernière modification : 2024/10/23 13:55
  • (modification externe)