Installing the git
client
Git comes in the Ubuntu packages.
sudo apt-get -y install git
After that, you can easily just create an empty Git repository wherever your code is.
cd /var/www/some-project
git init
git add some-file
git commit -m "First commit."
Although it can be argued that keeping version controlled files in /var/www
is not a good idea. You should probably only deploy projects there.
Managing git
repositories
If you want a Git server and push your stuff somewhere, you should look at Gitosis. On Ubuntu, that is:
sudo apt-get -y install gitosis
The Ubuntu community manual also has an extensive tutorial on setting up Gitosis, as well as the Arch wiki I linked to above. The default setup will take care of where to put your files, in this case /srv/gitosis
.
If you want more control, grab Gitosis from GitHub instead and change the --home
option for the home directory.
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /srv/git \
git
Then follow the steps in the manual (beware, the Ubuntu version has the user gitosis
, whereas the one from GitHub uses git
).
You'll find yet another tutorial here, so this stuff is fairly well documented.
repo inside web-root is extremely bad idea from the POV of security – Lazy Badger – 2012-02-16T22:06:52.000
why its bad security? – Yosef – 2012-02-16T22:13:26.100
possibility to open data in repo in case of site-hacks or server-misconfiguration – Lazy Badger – 2012-02-16T22:21:48.527
the repo should be under /srv/git/ and the code download from git to /var/www/ this what i mean – Yosef – 2012-02-17T09:52:02.170