chapter 4 notes
on the server
your remote repo is bare, no working directory; just .git
local network: git clone /path or git clone file:///path
ssh: git clone ssh://user@server:project.git or git clone user@server:project.git
(assumes ssh, assumes current user)
git: fast but no authentication, complex to setup
http: git clone http://example.com/gitproject.git
requires activation of default post update hook:
$ cd /var/www/htdocs/
$ git clone --bare /path/to/git_project gitproject.git
$ cd gitproject.git
$ mv hooks/post-update.sample hooks/post-update
$ chmod a+x hooks/post-update
Setup start to finish:
giving users access and perms:
1. create a single 'git' user on the machine:
sudo adduser git
su git
cd
mkdir .ssh
get everyone's SSH public key, and add those to the ~/.ssh/authorized_keys file of your new 'git' user:
$ cat /tmp/id_rsa.john.pub >> ~/.ssh/authorized_keys
(Other options: 2. adduser 3. LDAP)
Create bare repo:
$ cd /opt/git
$ mkdir project.git
$ cd project.git
$ git --bare init
On local, init, add, commit, push:
# on Johns computer
$ cd myproject
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin git@gitserver:/opt/git/project.git
$ git push origin master
Others can too:
$ git clone git@gitserver:/opt/git/project.git
$ vim README
$ git commit -am 'fix for the README file'
$ git push origin master
Also possible to restrict users from using other non-git shell
Gitosis uses a gitlike environ for managing repos and access
Gitolite has more perms, easier setup, scales
Git daemon uses git protocol.
Github:
Allows you to add other gh users by username
Find a project you like, fork it, change it, have original project owner pull changes back
Make your initial commit on local.
Then add github as a remote and push:
$ git remote add origin git@github.com:testinguser/project.git
$ git push origin master