rss

git : fiche pratique

Cet article est une fiche pratique (commandes de base) pour Git.
  • Client Windows : perso j'utilise Msysgit. Il y en a plein évidemment...
  • Git derrière un proxy ? 2 solutions :
 export http_proxy=http://user:pass@host:port
 git config --global http.proxy http://user:pass@host:port
  • Un problème de certificats SSL ?
 git config --global http.sslVerify false
  • Visualiser l'historique d'un dépôt (avec msysgit)
 gitk --all &
  • récupérer un dépôt distant
 git clone https://domain.com/repo.git
  • connaître l'état du dépot
 git status
  • indexer l'ensemble des modifications : supprimer les fichiers, ajouter les fichiers manquants ou modifiés
 git add --all .
  • annuler des modifications locales non commitées
 git reset --hard
  • résoudre un conflit (lors d'un merge ou cherry-pick..)
 git mergetool
  • creer un tag
 git tag -a monTag -m 'monTag Il est beau'
 git push --tags 
  • déplacer un tag sur la version actuelle
 git tag -f -a monTag 
 git push origin :refs/tags/monTag 
 git push --tags 
  • positionner des alias de commandes git : dans le fichier de config global (~/.gitconfig)
 [alias]
        #Basic
        co = checkout
        st = status -s
        ci = commit
        br = branch
        df = diff
        cp = cherry-pick
        cl = clone
        diff = diff --word-diff
        dc = diff --cached
        who = shortlog -s --
        r  = !git ls-files -z --deleted | xargs -0 git rm
        #revert last commit
        rollback = reset --soft HEAD~1
        #Commit using previous message
        reapply = commit -c ORIG_HEAD
        #Logs
        lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %an - %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
        #Les logs du user
        mylg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %an - %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative --author="Vincent\\ Bostoen"
        ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
        lol = log --graph --decorate --pretty=oneline --abbrev-commit
        lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
        #Lister les commits pas encore pushés
        ctp = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %an - %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative origin/master..master
        #Mettre un fichier en argument pour avoir ses modifications
        fl = log -u
        #Avoir le contenu du dernier commit
        dl = "!git ll -1"
        #Avoir le diff avec un commit
        diffr = "!f() { git diff "$1"^.."$1"; }; f"
        #Lister tous les chemins pour un nom de fichier
        f = "!git ls-files | grep -i"
        #Chercher tous les fichiers contenant une chaine de caractère
        gr = grep -Ii
        #Lister les alias
        la = "!git config -l | grep alias | cut -c 7-"
        #Remove all locally deleted file (git rm on all 'D' files)
        rma = "!git diff -z --name-only --diff-filter=D | xargs -0 git rm"
        #Stash
        sl = stash list
        sa = stash apply
        ss = stash save
        amend = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend
        ignore=!([ ! -e .gitignore ] && touch .gitignore) | echo $1 >>.gitignore
        up = !sh -c 'git pull --rebase --prune && git log --pretty=format:\"%Cred%ae %Creset- %C(yellow)%s %Creset(%ar)\" HEAD@{1}..'
        bt = for-each-ref --format='%(refname:short) <- heads="" pre="" refs="" upstream:short="">

Aucun commentaire:

Enregistrer un commentaire

Mots clés du blog

10.1 4G acceptancetest adb androï Android androïd Android7 api appender appengine application applications archive array assistantematernelle astuce auth0 authentication authority automation Axis bash bearer blog boot bootloader bower build bundle c calendrier camille combal cdi certificate cf client cloudfoundry collaboratif command commandes connexion console css cyanogen decrypt démasquées démasquer développement dll dump easter eggs écologie écrit employeur EMUI EMUI5.0 encrypt enfant évènement export-package ExtJS fab fastboot fiche find firefox gadget galaxytab gelf gem git gmail gnupg gooelappengine google gparted gpg gpg2 gps graylog grenoble Grid gui harddrive heroku hover howto HTML http https IE ihm immobilier imprimante innovation insolite instance integration Java JavaScript jenkins jeu jobs json json-schema-validator key keystore labs linux livre log log4j logger logs lombok masquées masquer maven maven-gae-plugin Mémoire microsoft mobile mockito mondialisation monitor MUSE musique en ligne myopera nodejs npm NT NTEventLogger onglet openstack osgi paas package parameters parent php politique prosyst prototype proxies proxy quartz radio rappel recherche regex repository resize RIA ridge rock ROM route ruby rubygems s8500 samsung scheduler scm secret secure sel selenium Serializer server shared shell sign signature slf4j smartphone so société song spy ssh ssl struct swagger swig tâches téléphone téléréalité test thunderbird timeout token Tomcat tooltip tooltips truststore TWRP ubuntu unit test validator verify virgin virtualbox wave waze web WebApp wiki wikimedia wikipédia wikipen wiko windows windows10 yahoo youtube yum