Git
De Linuxmemo.
Sommaire |
[modifier] install
apt-get install git-core gitk
[modifier] config et proxy
- Fichier de configuration ~/.gitconfig
[color] diff = auto status = auto branch = auto [user] name = votre_pseudo email = moi@email.com [alias] ci = commit co = checkout st = status br = branch [http] proxy = http://172.0.0.23:8080 [https] proxy = https://172.0.0.23:8080
- fichiers à ignorer dans le dépot .gitignore
$ cat .gitignore *.[oa] *~
[modifier] utilisation
[modifier] Def: états des fichiers
- sous suivi de version
- inchangés (unmodified)
- modifiés (modified)
- indexés (staged)
- non suivi
Cycle de vie: Quand vous clonez un dépôt pour la première fois, tous les fichiers seront sous suivi de version et inchangés car vous venez tout juste de les enregistrer sans les avoir encore édités. Au fur et à mesure que vous éditez des fichiers, Git les considère comme modifiés, car vous les avez modifiés depuis le dernier instantané. Vous indexez ces fichiers modifiés et vous enregistrez toutes les modifications indexées, puis ce cycle se répète.
[modifier] init
mkdir nom_depot cd nom_depot git init
[modifier] Cloner un dépot déjà existant
git clone http://github.com/symfony/symfony.git ou git clone http://github.com/symfony/symfony.git symfony pour le creer dans le répertoire "symfony"
[modifier] mise a jour
git pull
[modifier] etat
git status git log git log -p -2 git diff <commit1> <commit2>
[modifier] gestion des fichiers
git add <nom_fichier> git add --all <rep> # répertoire en recursif git rm <nom_fichier> git mv <nom_fichier> <nouvelle_destination>
[modifier] gestion des commit
git pull git commit <fichier1> <fichier2> git commit -a git push origin master
[modifier] annulation
git reset --hard HEAD git reset --hard HEAD^ git revert commit
[modifier] gestion des branches
git branch test git branch git checkout <nom_branche> git merge <nom_branche> git reset --hard HEAD
[modifier] récupération des changements
git remote add bob git://github.com/bob git fetch bob git merge bob/master git pull bob
[modifier] Attention au protocole
- local
git clone /opt/git/projet.git Ou bien cela : git clone file:///opt/git/projet.git
- distant
git:
git clone git://exemple.com/projetgit.git
http:
git clone http://exemple.com/projetgit.git
https:
git clone https://exemple.com/projetgit.git
ssh:
git clone ssh://utilisateur@serveur:projet.git ou git clone utilisateur@serveur:projet.git
[modifier] Interface graphique
- gitk
Ce placer dans le répertoire du dépot puis: gitk
- git-gui
git gui [<command>] [arguments]
- git-cola
[modifier] Livre
[modifier] Ressources
git reset --hard HEAD; git clean -f -d; git pull
- git pull total script
#!/bin/bash syntaxe () { echo "Usage:" echo "`basename $0` reset #Pour un RESET complet de tous les sites" echo "`basename $0` update #Pour seulement un UPDATE complet de tous les sites" } gitreset () { for i in $(ls) do if [ -d $i ] ;then cd $i echo -------- pwd echo -------- git reset --hard HEAD git clean -f -d git pull cd .. fi done } gitupdate () { for i in $(ls) do if [ -d $i ] ;then cd $i echo -------- pwd echo -------- git pull cd .. fi done } case "$1" in reset) gitreset ;; update) gitupdate ;; *) syntaxe exit 1 esac
[modifier] Mes URLs
url = https://github.com/chrisallenlane/cheat.git url = git@github.com:Redhook/scripts.git url = https://github.com/Arachni/arachni.git url = https://github.com/sqlmapproject/sqlmap.git url = https://github.com/rebootuser/LinEnum url = https://github.com/KvasirSecurity/Kvasir.git url = https://github.com/sullo/nikto.git url = https://github.com/trustedsec/social-engineer-toolkit.git url = https://git.code.sf.net/p/gtk-curl/code url = https://github.com/jorhett/learning-puppet4 url = https://github.com/magnumripper/JohnTheRipper.git url = https://github.com/google/gdata-python-client.git url = https://github.com/offensive-security/exploit-database.git url = https://github.com/centreon/centreon-clapi.git u rl = https://github.com/andresriancho/w3af.git url = https://github.com/grwl/sslcaudit.git url = https://github.com/rapid7/metasploit-framework url = https://github.com/zaproxy/zaproxy.git url = https://github.com/jaredsburrows/Rarcrack.git url = https://github.com/mamute/cheatsheets.git url = https://github.com/Arachni/arachni-ui-web.git url = https://github.com/vinitkumar/googlecl.git url = https://github.com/MalwareReverseBrasil/malwaresearch url = https://github.com/web2py/web2py.git url = https://github.com/sd65/MiniVim.git url = https://github.com/wireghoul/dotdotpwn.git url = https://github.com/letsencrypt/letsencrypt url = https://github.com/dradis/dradisframework.git url = https://github.com/Yubico/yubikey-personalization-gui.git url = https://github.com/hashcat/hashcat.git url = https://github.com/KhronosGroup/OpenCL-Headers.git url = https://github.com/psypanda/hashID.git url = https://github.com/zaproxy/zap-extensions.git url = https://github.com/lanmaster53/recon-ng.git url = https://github.com/andrewjkerr/security-cheatsheets.git url = https://github.com/beefproject/beef.git url = https://github.com/zrlram/afterglow
[modifier] Astuces
Afficher l'url d'un site distant:
git remote -v
- lister les urls
find . -type d -maxdepth 1 -exec grep url {}/.git/config \;