Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docpublic:systemes:linux:git [2013/04/09 10:05]
PROCACCIA [Configuration]
docpublic:systemes:linux:git [2013/04/09 13:54] (current)
PROCACCIA
Line 2: Line 2:
 ===== GIT ===== ===== GIT =====
  
-===== Reference =====+===== References =====
  
   * http://www.siteduzero.com/informatique/tutoriels/gerez-vos-codes-source-avec-git   * http://www.siteduzero.com/informatique/tutoriels/gerez-vos-codes-source-avec-git
Line 11: Line 11:
   * http://www.fclose.com/b/linux/366/set-up-git-server-through-ssh-connection/   * http://www.fclose.com/b/linux/366/set-up-git-server-through-ssh-connection/
   * http://othiebaut.developpez.com/tutoriels/general/git-on-debian/   * http://othiebaut.developpez.com/tutoriels/general/git-on-debian/
 +  * http://git-scm.com/book/fr/Les-bases-de-Git-Travailler-avec-des-d%C3%A9p%C3%B4ts-distants
  
 ===== Configuration locale ===== ===== Configuration locale =====
Line 222: 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 228: 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 243: 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 318: Line 319:
 </code> </code>
  
 +===== ssh git server =====
  
 +==== cle ssh ====
  
 +echange de clé avant "fermeture" du shell gituser
 +
 +<code>
 +$ ssh-keygen -t rsa
 +Generating public/private rsa key pair.
 +Enter file in which to save the key (/home/gituser/.ssh/id_rsa): 
 +Created directory '/home/gituser/.ssh'.
 +
 +
 +[login@arvouin ~/.ssh]
 +$ ssh-copy-id gituser@svnshare.it-sudparis.eu
 +</code>
 +
 +==== configuration gituser ====
 +
 +<code>
 +# yum install git
 +# useradd -m -d /home/gituser gituser
 +# usermod -s /usr/bin/git-shell gituser
 +# tail -2 /etc/shells
 +/bin/csh
 +/usr/bin/git-shell 
 +# mkdir git-shell-commands
 +# chmod 755 git-shell-commands
 +# cp /usr/share/doc/git-1.7.4.1/contrib/git-shell-commands/* /home/gituser/git-shell-commands/
 +# chown -R gituser /home/gituser/git-shell-commands/*
 +# chmod +x /home/gituser/git-shell-commands/list /home/gituser/git-shell-commands/help 
 +</code>
 +
 +au sujet de git-shell-commands cf http://serverfault.com/questions/285324/git-shell-not-enabled/325484#325484
 +==== git bare server repo ====
 +
 +on creer un repository vierge sur le serveur
 +
 +<code>
 +# su -s /bin/bash - gituser
 +$ mkdir gittuto.git
 +$ cd gittuto.git/
 +$ git --bare init
 +Initialized empty Git repository in /home/gituser/gittuto.git/
 +</code>
 +
 +
 +===== 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]
 +
 +<code>
 +$ git remote add tuto ssh://gituser@gitshare.tem-tsp.eu/~/gittuto.git
 +</code>
 +
 +verification de la declaration et des repo remote disponibles
 +<code>
 +$ git remote -v 
 +tuto ssh://gituser@gitshare.tem-tsp.eu/~/gittuto.git (fetch)
 +tuto ssh://gituser@gitshare.tem-tsp.eu/~/gittuto.git (push)
 +</code>
 +
 +==== git push ====
 +
 +on pousse alors notre depot (branche master) local vers le serveur
 +
 +<code>
 +$ 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://gituser@gitshare.tem-tsp.eu/~/gittuto.git
 + * [new branch]      master -> master
 +</code>
 +
 +sur le serveur le directory "objects" a evolué
 +
 +<code>
 +[gituser@gitshare gittuto.git]$ ls -ltra
 +drwxrwxr-x  4 gituser gituser 4096 Apr  9 14:54 refs
 +drwxrwxr-x  2 gituser gituser 4096 Apr  9 14:54 info
 +drwxrwxr-x  2 gituser gituser 4096 Apr  9 14:54 hooks
 +-rw-rw-r--  1 gituser gituser   23 Apr  9 14:54 HEAD
 +-rw-rw-r--  1 gituser gituser   73 Apr  9 14:54 description
 +-rw-rw-r--  1 gituser gituser   66 Apr  9 14:54 config
 +drwxrwxr-x  2 gituser gituser 4096 Apr  9 14:54 branches
 +drwxrwxr-x  7 gituser gituser 4096 Apr  9 14:54 .
 +drwxrwxr-x 16 gituser gituser 4096 Apr  9 15:08 objects
 +</code>
 +
 +===== usages client remote =====
 +
 +depuis un (autre) client (teststud) on va recuperer ce repo et le modifier
 +
 +<code>
 +$ ssh-copy-id gituser@gitshare.tem-tsp.eu
 +
 +$ git clone ssh://gituser@gitshare.tem-tsp.eu/~/gittuto.git
 +Cloning into 'gittuto'...
 +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://gituser@gitshare.tem-tsp.eu/~/gittuto.git (fetch)
 +origin ssh://gituser@gitshare.tem-tsp.eu/~/gittuto.git (push)
 +</code>
 +
 +modifications et ajouts locaux
 +
 +<code>
 +-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(+), 0 deletions(-)
 + create mode 100644 file2.txt
 +</code>
 +
 +==== push remote ====
 +
 +on envoie sur le serveur nos modifications
 +
 +<code>
 +-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://gituser@gitshare.tem-tsp.eu/~/gittuto.git
 +   8fedaa6..9287d44  master -> master
 +</code>
 +
 +sur le serveur, c'est encore le directory "objects" qui viens d'etre modifié
 +
 +<code>
 +[root@gitshare gittuto.git]# ls -ltr | tail -2
 +drwxrwxr-x  2 gituser gituser 4096 Apr  9 14:54 branches
 +drwxrwxr-x 19 gituser gituser 4096 Apr  9 15:26 objects
 +</code>
 +
 +==== pull remote ====
 +
 +depuis notre premier client nous allons recuperer les modifications faites par le second client (teststud)
 +
 +=== visualisation de l'etat remote ===
 +
 +<code>
 +$ git remote show tuto
 +* remote tuto
 +  Fetch URL: ssh://gituser@gitshare.tem-tsp.eu/~/gittuto.git
 +  Push  URL: ssh://gituser@gitshare.tem-tsp.eu/~/gittuto.git
 +  HEAD branch: master
 +  Remote branch:
 +    master tracked
 +  Local ref configured for 'git push':
 +    master pushes to master (local out of date)
 +</code>
 +
 +on note le "(local out of date)" !.
 +
 +=== recuperation ===
 +
 +on recupere (pull) depuis le serveur les dernieres modifications du repo "tuto" dans notre branche "master"
 +
 +<code>
 +$ git pull tuto master
 +From ssh://gitshare.tem-tsp.eu/~/gittuto
 + * branch            master     -> FETCH_HEAD
 +Updating 8fedaa6..9287d44
 +Fast-forward
 + file2.txt |    2 ++
 + 1 files changed, 2 insertions(+), 0 deletions(-)
 + create mode 100644 file2.txt
 +
 +$ ls
 +file1.txt  file2.txt
 +
 +</code>
docpublic/systemes/linux/git.1365501948.txt.gz · Last modified: 2013/04/09 10:05 by PROCACCIA
[unknown link type]Back to top
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0