Search

Dark theme | Light theme

December 14, 2009

Getting Local Git Repo to the Server

Just a little remainder to myself on how to get my local Git repository to the server. The server repository can be accessed through SSH to push and pull changes. The steps are easy, but I always have to Google for it when I need to follow the steps, because I can't remember them. So now I only have to look at my own blog to get the correct steps.

$ mkdir projectdir
$ cd projectdir
$ git init
$ touch README
$ git add README
$ git commit -m "Initial commit"
$ cd ..
$ git clone --bare projectdir projectdir.git
$ scp -r projectdir.git user@server.com:/git-repo
$ cd projectdir
$ git remote add origin ssh://user@server.com/git-repo/projectdir.git
Now we can use $ git push to push changes to the server.
And we can use $ git clone user@server.com/git-repo/projectdir.git to clone the server repository on a local computer.