This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docpublic:systemes:linux:git [2013/04/09 09:31] PROCACCIA [branch master] |
docpublic:systemes:linux:git [2013/04/09 13:54] (current) PROCACCIA |
||
---|---|---|---|
Line 2: | Line 2: | ||
===== GIT ===== | ===== GIT ===== | ||
- | ===== Reference | + | ===== References |
* http:// | * http:// | ||
Line 8: | Line 8: | ||
* http:// | * http:// | ||
* https:// | * https:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
- | ===== Configuration ===== | + | ===== Configuration |
Line 219: | Line 223: | ||
$ git log | $ git log | ||
commit 9c17567714d9158126d39d3b1dda20ebe5146d82 | commit 9c17567714d9158126d39d3b1dda20ebe5146d82 | ||
- | Author: jehanproc <jehan.procaccia@int-evry.fr> | + | Author: jehanproc <my.email@int-evry.fr> |
Date: Tue Apr 9 11:18:36 2013 +0200 | Date: Tue Apr 9 11:18:36 2013 +0200 | ||
Line 225: | Line 229: | ||
commit b679adb3b2e2fa5e30d1f52b2fa4f12cff888b66 | commit b679adb3b2e2fa5e30d1f52b2fa4f12cff888b66 | ||
- | Author: jehanproc <jehan.procaccia@int-evry.fr> | + | Author: jehanproc <my.email@int-evry.fr> |
Date: Tue Apr 9 09:51:01 2013 +0200 | Date: Tue Apr 9 09:51:01 2013 +0200 | ||
Line 240: | Line 244: | ||
$ git log | $ git log | ||
commit b679adb3b2e2fa5e30d1f52b2fa4f12cff888b66 | commit b679adb3b2e2fa5e30d1f52b2fa4f12cff888b66 | ||
- | Author: jehanproc <jehan.procaccia@int-evry.fr> | + | Author: jehanproc <my.email@int-evry.fr> |
Date: Tue Apr 9 09:51:01 2013 +0200 | Date: Tue Apr 9 09:51:01 2013 +0200 | ||
Line 297: | Line 301: | ||
</ | </ | ||
+ | commit | ||
+ | < | ||
+ | $ git commit -a -m "marge master et option1, resolution conflit file1" | ||
+ | [master 8fedaa6] marge master et option1, resolution conflit file1 | ||
+ | $ git status | ||
+ | # On branch master | ||
+ | nothing to commit (working directory clean) | ||
+ | </ | ||
+ | |||
+ | Destruction de branche . | ||
+ | |||
+ | < | ||
+ | $ git branch -d option1 | ||
+ | Deleted branch option1 (was 9c17567). | ||
+ | </ | ||
+ | |||
+ | ===== ssh git server ===== | ||
+ | |||
+ | ==== cle ssh ==== | ||
+ | |||
+ | echange de clé avant " | ||
+ | |||
+ | < | ||
+ | $ ssh-keygen -t rsa | ||
+ | Generating public/ | ||
+ | Enter file in which to save the key (/ | ||
+ | Created directory '/ | ||
+ | |||
+ | |||
+ | [login@arvouin ~/.ssh] | ||
+ | $ ssh-copy-id gituser@svnshare.it-sudparis.eu | ||
+ | </ | ||
+ | |||
+ | ==== configuration gituser ==== | ||
+ | |||
+ | < | ||
+ | # yum install git | ||
+ | # useradd -m -d / | ||
+ | # usermod -s / | ||
+ | # tail -2 /etc/shells | ||
+ | /bin/csh | ||
+ | / | ||
+ | # mkdir git-shell-commands | ||
+ | # chmod 755 git-shell-commands | ||
+ | # cp / | ||
+ | # chown -R gituser / | ||
+ | # chmod +x / | ||
+ | </ | ||
+ | |||
+ | au sujet de git-shell-commands cf http:// | ||
+ | ==== git bare server repo ==== | ||
+ | |||
+ | on creer un repository vierge sur le serveur | ||
+ | |||
+ | < | ||
+ | # su -s /bin/bash - gituser | ||
+ | $ mkdir gittuto.git | ||
+ | $ cd gittuto.git/ | ||
+ | $ git --bare init | ||
+ | Initialized empty Git repository in / | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== initialisation git remote client ===== | ||
+ | |||
+ | sur le client on declare notre serveur remote qui va heberger notre repo | ||
+ | |||
+ | ==== remote add ==== | ||
+ | |||
+ | syntaxe: git remote add [nomcourt] [url] | ||
+ | |||
+ | < | ||
+ | $ git remote add tuto ssh:// | ||
+ | </ | ||
+ | |||
+ | verification de la declaration et des repo remote disponibles | ||
+ | < | ||
+ | $ git remote -v | ||
+ | tuto ssh:// | ||
+ | tuto ssh:// | ||
+ | </ | ||
+ | |||
+ | ==== git push ==== | ||
+ | |||
+ | on pousse alors notre depot (branche master) local vers le serveur | ||
+ | |||
+ | < | ||
+ | $ git push tuto master | ||
+ | Counting objects: 12, done. | ||
+ | Delta compression using up to 2 threads. | ||
+ | Compressing objects: 100% (4/4), done. | ||
+ | Writing objects: 100% (12/12), 917 bytes, done. | ||
+ | Total 12 (delta 1), reused 0 (delta 0) | ||
+ | To ssh:// | ||
+ | * [new branch] | ||
+ | </ | ||
+ | |||
+ | sur le serveur le directory " | ||
+ | |||
+ | < | ||
+ | [gituser@gitshare gittuto.git]$ ls -ltra | ||
+ | drwxrwxr-x | ||
+ | drwxrwxr-x | ||
+ | drwxrwxr-x | ||
+ | -rw-rw-r-- | ||
+ | -rw-rw-r-- | ||
+ | -rw-rw-r-- | ||
+ | drwxrwxr-x | ||
+ | drwxrwxr-x | ||
+ | drwxrwxr-x 16 gituser gituser 4096 Apr 9 15:08 objects | ||
+ | </ | ||
+ | |||
+ | ===== usages client remote ===== | ||
+ | |||
+ | depuis un (autre) client (teststud) on va recuperer ce repo et le modifier | ||
+ | |||
+ | < | ||
+ | $ ssh-copy-id gituser@gitshare.tem-tsp.eu | ||
+ | |||
+ | $ git clone ssh:// | ||
+ | Cloning into ' | ||
+ | remote: Counting objects: 12, done. | ||
+ | remote: Compressing objects: 100% (4/4), done. | ||
+ | remote: Total 12 (delta 1), reused 0 (delta 0) | ||
+ | Receiving objects: 100% (12/12), done. | ||
+ | Resolving deltas: 100% (1/1), done. | ||
+ | -bash-4.2$ ls | ||
+ | gittuto | ||
+ | -bash-4.2$ cd gittuto/ | ||
+ | -bash-4.2$ ls | ||
+ | file1.txt | ||
+ | -bash-4.2$ git remote -v | ||
+ | origin ssh:// | ||
+ | origin ssh:// | ||
+ | </ | ||
+ | |||
+ | modifications et ajouts locaux | ||
+ | |||
+ | < | ||
+ | -bash-4.2$ vim file2.txt | ||
+ | -bash-4.2$ git add file2.txt | ||
+ | -bash-4.2$ git commit -a -m "add file2" | ||
+ | [master 9287d44] add file2 | ||
+ | |||
+ | 1 files changed, 2 insertions(+), | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ==== push remote ==== | ||
+ | |||
+ | on envoie sur le serveur nos modifications | ||
+ | |||
+ | < | ||
+ | -bash-4.2$ git push | ||
+ | Counting objects: 4, done. | ||
+ | Delta compression using up to 2 threads. | ||
+ | Compressing objects: 100% (2/2), done. | ||
+ | Writing objects: 100% (3/3), 307 bytes, done. | ||
+ | Total 3 (delta 0), reused 0 (delta 0) | ||
+ | To ssh:// | ||
+ | | ||
+ | </ | ||
+ | |||
+ | sur le serveur, c'est encore le directory " | ||
+ | |||
+ | < | ||
+ | [root@gitshare gittuto.git]# | ||
+ | drwxrwxr-x | ||
+ | drwxrwxr-x 19 gituser gituser 4096 Apr 9 15:26 objects | ||
+ | </ | ||
+ | |||
+ | ==== pull remote ==== | ||
+ | |||
+ | depuis notre premier client nous allons recuperer les modifications faites par le second client (teststud) | ||
+ | |||
+ | === visualisation de l'etat remote === | ||
+ | |||
+ | < | ||
+ | $ git remote show tuto | ||
+ | * remote tuto | ||
+ | Fetch URL: ssh:// | ||
+ | Push URL: ssh:// | ||
+ | HEAD branch: master | ||
+ | Remote branch: | ||
+ | master tracked | ||
+ | Local ref configured for 'git push': | ||
+ | master pushes to master (local out of date) | ||
+ | </ | ||
+ | |||
+ | on note le " | ||
+ | |||
+ | === recuperation === | ||
+ | |||
+ | on recupere (pull) depuis le serveur les dernieres modifications du repo " | ||
+ | |||
+ | < | ||
+ | $ git pull tuto master | ||
+ | From ssh:// | ||
+ | * branch | ||
+ | Updating 8fedaa6..9287d44 | ||
+ | Fast-forward | ||
+ | | ||
+ | 1 files changed, 2 insertions(+), | ||
+ | | ||
+ | |||
+ | $ ls | ||
+ | file1.txt | ||
+ | |||
+ | </ |