Git
Attention au commit initial (Head): Toujours vide avec juste le readme.md vide.
Si fichiers sensibles (mot de passe, privé, …) faire un git ignore
Head
Prod
Prod
Dev
Dev1 Commit
Dev2 Commit
Dev
Suite
Prod
gitBash (ligne de commande)
Ouvrir gitbash à partir du dossier
Pour créer un depot distant : git remote add depot_distant
[email protected]:utilisateur/depot_utilisateur.git
Le truc qui marche :
Mais, le plus simple est de créer sur l’interface WEB (gitlab, github, …)
Dans un dossier vide :
Git clone https://github.com/michaeldalian/WorkOnJSON.git
Puis aller dans le dossier que git a créé WorkOnJSON et copier le dossier git et le readme
Les coller dans le dossier ou se trouve notre code.
Ouvrir un gitbash sur ce dossier
git add .
git commit -m"first"
Git push origin master
Fin.
1) créer le repos en local à partir d’un dossier existant : Git clone
https://gitlab.com/labo-ve/cda/cda-2/Michael_D.git
(ou alors partir d’un dossier local vide : Initialiser le dossier : git init)
2) Ouvrir un git bash sur le dossier créé (WorkOnJSON)
3)
git remote set-url origin https://github.com/michaeldalian/WorkOnJSON.git
4) Ajouter fichiers ajouter tout : git add .
5) Flag fichiers « à poster » : git commit -m "Initial commit pocone angular"
Tous les fichiers :
6) Envoyer fichiers flagués: Git push origin master
Branche merge : git pull –rebase
OU rebase (sans historique) :
1) Je me place la branche de référence (d’où je suis parti) : git
checkout ref_branche
2) Je fusionne ma branche avec la ref : git rebase ma_branche
Ou
git rebase ma_branche ref_branche
7) Se placer dans le dossier de la branche principale MASTER
8) Crée la branche dev et se place dessus : git checkout –b DEV
(raccourci de : git branch DEV puis git checkout DEV)
9) Se placer sur une branche : git checkout [dossier] (Ex : git checkout master)
ls
git push --set-upstream origin PHP
git branch --set-upstream-to=origin/DEV
git branch --set-upstream-to= "https://github.com/michaeldalian/WorkOnJSON.git"
git branch --set-upstream-to= "https://gitlab.com/labo-ve/cda/cda-2/Michael_D.git/PHP"
git branch -set-upstream-to=repository/https://gitlab.com/labo-ve/cda/cda-
2/A_supprimer.git/Michael
https://gitlab.com/gaspacchio/travel-news.git
m_dalian.labo-ve.fr
remote add origin "https://github.com/michaeldalian/PHP.git"
git push --set-upstream origin MASTER
origin est un nom standard, ça bouge pas
git log –graph –online
affiche tous les commits
Créer un repo (pointe sur un dossier)
Créer le repo avec le client web (avec README.md, git ignore php)
Ouvrir un git bash sur le dossier et taper :
git clone https://github.com/michaeldalian/NomDeMonRepo.git
Il crée le dossier NomDeMonRepo.
Je peux le renommer, par ex : NomDeMonDossier
Je peux déplacer le contenu du dossier créé dans le dossier de mon appli et ouvrir une
console dessus
Je peux déplacer le dossier git dans le dossier de mon appli
Se placer sur le dossier :
cd NomDeMonDossier
ou ouvrir nouvelle console dessus
Taper : git status (me dit les fichiers ajoutés)
add .
commit –m”blabla”
Git push origin master
Git fetch : récupère le repo distant
Git fetch origin <nom de la branche>
La commande git fetch va récupérer toutes les données des commits effectués sur la branche
courante qui n'existent pas encore dans votre version en local. permet de garder son répertoire de
travail à jour et de contrôler le moment où l'on souhaite fusionner les données.
En vert, ce qui a été ajouté, en rouge, enlevé
Pull = Fetch + merge
En cas de conflit :
Git pull origin master.
Git log
Git stash (sauve ton code)
Git diff (affiche les différences avec le master)
Issue : à partir de github, gitlab.
git remote set-url origin https://github.com/michaeldalian/WorkOnJSON.git