Category Archives: git

Setting up a git repository on

For private us, I have been using git for quite a while now. Git is simple enough to use, has plenty of net-coverage and is probably not going away anytime soon, so seems a good choice. A friend asked to use a script I use regularly and it seemed a good idea to finally start putting my scripts on-line. Others can clone my scripts and I can get to them if I am on a remote computer.

There are a whole list of public git servers out there, but I decided to go for maintained by Petr Baudis. It has a basic web interface for creating or forking projects and was the first public Git hosting site (info from here, which has a whole list of public git servers).

To start using git you have to install it off course, on Debian/Ubuntu this can be done with a simple:

sudo apt-get install git-core

But there are packages for most common OSes here.

Setting up a repo on

Ok, first we have to add ourselves as a user to For that we need to create an ssh-key, good tutorials are this one or this one.

Copy your public key, located in ~/.ssh/ to, fill out login and email information, and the first step is done.

Next, add a new project here (For example I used SimpleScripts). It will give a new repo like this:

fatal: no matching remote head

Now comes the weird part. Initially I had the idea to pull the repo, move my stuff into it, commit it and I would be done, but no, that is not how it works.

What will happen is this:

$ git clone ssh://
Initialized empty Git repository in /home/user/git/SimpleScripts/.git/
fatal: no matching remote head

Which is git’s way of saying the remote repo is empty. Right. Here I found the answer. It is actually quite logical, you want to push stuff you already have to the web, so you must start locally, and push that to your new repo.

$ git init #make a new repo, or use one you made earlier

Now we add some content:

$ touch README
$ git add README
$ git commit -a -m "First commit."

Next we have to edit the git config file:

$ $EDITOR .git/config

and add the following to the bottom:

[branch "master"]
remote = origin
merge = refs/heads/master

[remote “origin”] should be there already. Now we do:

$ git push origin master

This will push your content to remote and from now on pushing/pulling will
work as we expected.

I am happy Richard Jones figured all this out already 🙂 Thanks!

Now I can add the wp-all script I did all this for. It is a small script to automate local wordpress installs to work on themes and play around. It pushes the ne wp install in git as well, so you can keep track of changes.


Leave a comment

Filed under git