Posted on Sunday, June 1st, 2014 at 10:20 pm
How to configure git on a Linux web server.
To set up a git server you will need two directories on your server, one for the repository files and another to make changes to your files in, known as your working files. Generally you will keep your working files in
/var/www/domain.com/ and your repository files in
/repo/domain.com/ but some operating systems may have a different file structure. If you don't already have a
/repo/domain.com/ on your system, you'll need to create one:
$ mkdir -p /repo/domain.com/
Change into the domain directory in <code>/repo/</code> and create a bare repository:
$ cd /repo/domain.com/ $ git --bare init
Now change into your working files directory and clone this repository (it is currently still an empty repository):
$ cd /var/www/ $ git clone ssh://email@example.com/repo/domain.com ./domain.com
Now add your files for your website to
/var/www/domain.com/ and add the files in git:
$ git add .
Commit your changes to git:
$ git commit -m 'initial commit'
Push your changes to the bare git repository you created in
$ git push
If you're working with other developers you'll need to pull before you push your commits
$ git pull