Git: How to create a repository on a web server

David Nash bash, linux 1 Comment

I’m writing this mainly for my own reference. I found it very difficult to find instructions on using git for what I wanted.

The scenario: I have a web server (, which I can ssh into. It has a website running on /var/www/website/. I want to create a git repo for it, and then from my development machine (devmachine) clone that repo, make changes, and when I’m happy push them to the web server.

I already have ssh keys installed so I can ssh from devmachine to

On both and devmachine I have a user david who is in the group www-data.

Git on the server

First I need to create somewhere to store the project:

Okay, great! After creating the place to store it, I then went into the website directory and told it that the project is stored in my home directory. I then go back to my home directory and change the group permissions to www-data, so that I can push to it remotely, from devmachine.

Git on the development machine

I clone the repo I created, and then create a file called “test” to make sure I can push it to the server.

Back to the server

And there’s my test file, on the server! Now I can work locally, and when I’m ready push them to the server. I then ssh to the server and pull the changes to make them live.

Comments 1

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.