Last active
December 20, 2015 14:49
-
-
Save jimmylatreille/6149352 to your computer and use it in GitHub Desktop.
git commande reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//instalation sur linux | |
sudo apt-get install git | |
//for ui git in terminal | |
curl -L http://install.ohmyz.sh | sh | |
//télécharger git | |
http://git-scm.com/downloads | |
//interface pour gérer git | |
gitk | |
gitk --all | |
//voir les rpertoires même les chachés | |
ls -al | |
//créer des alias que l'ont appel par la suite dans cette exemple: gl | |
alias gl='git log --oneline --graph --all --decorate' | |
/*======================= GIT CONFIG =========================*/ | |
//pour les infos du user git | |
git config --global user.name "userName" | |
git config --global user.email email@email.com | |
//pour modifier la couleur dans l'invite de commande | |
git config --global color.ui true | |
//pour modifier l'éditeur par default | |
git config --gloabal core.editor "C:/Chemein/vers/votre/editor.exe' -w" | |
//pour modifier pour notepad++ | |
git config --global core.editor "C:/Program Files/Notepad++/notepad++.exe'-multilnst -notabbar -nosession -noPlugin" | |
/*======================= GIT REMOTE =========================*/ | |
git remote -v | |
git remote add origin https://git...... // chemin http | |
git remote add origin git@github.com...... // chemin ssh | |
//pour enlever un remote | |
git push origin :nouvelleBrnache | |
/*=================== SSH RSA KEYGEN METHOD ==================*/ | |
https://help.github.com/articles/generating-ssh-keys | |
//pour voir si ont a une paire de clé public et privé | |
cd ~/.ssh | |
ls | |
//creer la pair de clé public privé | |
ssh-keygen -t rsa -C "your_email@example.com" | |
/*======================= GIT init =========================*/ | |
//pour initialiser un repertoire | |
git init | |
/*======================= GIT ADD =========================*/ | |
//pour ajouter au stage | |
git add fileName.txt | |
git add * | |
git add . | |
/*======================= GIT COMMIT =========================*/ | |
git commit -m 'message du projet' | |
//pour faire un add, commit et le message en même temps | |
git commit -am 'message du commit' | |
/*======================= GIT STATUS =========================*/ | |
//pour voir le status du stage | |
git status | |
/*======================= GIT LOG =========================*/ | |
//pour voir les historique des commit | |
git log --stat --all --oneline --graph --decorate | |
git reflog | |
/*======================= GIT DIFF==== =====================*/ | |
//affiche les différences entre la copie de travail et la version la plus recente | |
git diff | |
//pour comparer les fichier de travail et le dernier depot en ignorant le stage | |
git diff HEAD nomDuFichier | |
git diff --cached nomDuFichier | |
git diff --staged nomDuFichier //pour comparer le fichier de la zone de stage avec le dernier commit | |
/*======================= GIT BRANCH =========================*/ | |
//Pour voir les branch | |
git branch | |
//pour voir egalement les remote | |
git branch -a | |
git branch -r | |
//pour créer une nouvelle branche | |
git branch nouvelleBranche | |
//Pour supprimer une branche | |
git branch -d nouvelleBranche | |
//pour supprimer une branch sur le local et sur le repo | |
git branch -D nouvelleBranche | |
/*======================= GIT CHECKOUT =========================*/ | |
//Pour changer de branche | |
git checkout nouvelleBranche | |
git checkout 2de2f.... //nom de hachage du commit | |
git checkout -b nomAutreNouvelleBranche //créer une branche si elle n'existe et pas et ce positionne deçu | |
/*======================= GIT MERGE =========================*/ | |
//Pour fusionner une branche | |
git merge nouvelleBranche | |
git mergetool --tool | |
/*======================= GIT PUSH =========================*/ | |
git push -u origin nomDeLaBranche //pour televerser | |
/*======================= GIT PULL =========================*/ | |
git pull origin master //pour recupéré des fichier a distance | |
/*======================= GIT FETCH =========================*/ | |
git fetch / pour récupéré sans fusionner a distance | |
/*======================= GIT CLONE =========================*/ | |
git clone git@github.com.... | |
//Clone a specifique branch | |
git clone -b my-branch git@github.com:user/myproject.git | |
/*======================== GIT DELETE BRANCH =============== */ | |
git push origin --delete branchName | |
/*========= Going back to the last commit if add accidentely =========*/ | |
git reset --hard HEAD | |
//going back in the commit head | |
git fetch origin | |
git reset --hard origin/master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment