Git

Créé le 21/09/2014

Dernière mise à jour le 22/04/2022

Étiquettes

Paramétrage :

git config --global user.name "name"
git config --global user.email "mail@mail.mail"

git config --global core.editor "vim" // ou emacs ou... votre éditeur préféré.
git config --global core.excludesfile ~/.gitignore // adapter le chemin vers l'emplacement où vous aurez mis le fichier .gitignore global. 
git config --global color.ui true
git config --global core.autocrlf false
git config --global core.safecrlf false
git config --global core.ignorecase false
git config --global diff.renames copies


git config --global alias.st 'status'
git config --global alias.co 'checkout'
git config --global alias.up 'pull --rebase'
git config --global alias.sl 'log --graph --pretty=oneline --abbrev-commit --decorate'
git config --global alias.slp 'log --graph --pretty=format:"%h%x09%an%x09%ad%x09%s" --abbrev-commit --decorate'
git config --global alias.lg "log --graph --date=relative --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ad)%Creset'"
git config --global alias.lga "log --graph --abbrev-commit --pretty=format:'%C(red)%h%Creset -%C(yellow)%d%Creset %s %C(green)(%cr) %C(bold blue)<%an>%Creset' --all"

Paramétrage optionnel :

git config --global core.filemode false // Si vous voulez ignorer les modifications de permissions de fichier.
git config --global branch.autosetuprebase always // Pour appliquer par défaut l'option --rebase

Fichier .gitignore global:

# Patch/diff artifacts.
*.patch
*.diff
*.orig
*.rej
interdiff*.txt

# emacs artifacts.
*~
\#*\#

# VI swap file.
*.swp

# Hidden files.
.DS*
.project

# Windows links.
*.lnk

# Temporary files.
tmp*

# Exclude IDE's project directory.
nbproject
.idea

# Package management systems.
bower_components
node_modules
vendor
yarn-error.log

Commandes :

git init

git remote add nom_remote URL

git clone URL

git add .
git add file
git add -p
git rm file
git checkout .
git checkout file

git diff
git diff file

git commit
git commit -m "message"
git commit --amend

git pull --rebase
git push -u nom_remote branche
git push -u nom_remote branche_locale:branche_sur_remote

git log

git checkout numero_commit
git checkout nom_branche
git checkout -b nom_nouvelle_branche
git checkout -b nom_nouvelle_branche --track nom_branche_à_tracker

git stash
git stash pop

git cherry-pick numero_commit

git rebase -i HEAD~nombre_commits

git tag -a nom_tag -m 'message de tag'

git apply -v filename.patch
git format-patch origin/[branchname] --stdout > [project_name]-[short-description]-[issue-number]-[comment-number].patch

git remote prune nom_remote

git add my_file && git commit --amend --no-edit && git push --force-with-lease

Ressources supplémentaires :

Commentaires

Soumis par Raoul (non vérifié) le ven, 11/28/2014 - 14:33 - Permalien

Il me semble que dans les versions récentes de git la commande "git config --global core.fileMode false" se fait sans "M" majuscule soit "git config --global core.filemode false"

Ajouter un commentaire