Blog Moved

Friday, January 24, 2014

Setting Up a Private Git Repo

For some time now, I've been running my own git repository on a server to which I have ssh access (since it's mine). Mostly, this hosts copies of various websites I run, such as my own personal site and various course-related sites. It makes it easy for me to be able to update the sites from different machines without things getting out of sync.

Details for how to do this are here:
  http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server
But since I'm the only user, I didn't need to set up a special git user, as described there. The point of doing that is to allow multiple people to access the repo (though you could also manage that just with file permissions, if they all have shell access anyway). The only thing I actually had to do, then, was to set up the repositories on the server and commit stuff to them.

Since I occasionally need to create new repos, here are the steps.

On the server:
# cd /git
# mkdir /newrepo
# cd newrepo
# git --bare init 
It actually doesn't matter where you put the repos. But putting them in some central location makes a lot of sense, right?

Then, on the client where I've got the stuff I want to put in that repo:
# cd /path/to/local/
# git init
# git add <files>
# git commit -a -m "Initial commit."
# git remote add origin myserver.com:/git/newrepo
# git push --set-upstream origin master
On various other clients, I can then clone the new repo as usual:
# git clone ssh://myserver.com/git/newrepo
 Of course, this doesn't allow anyone else access, even read-only access. But since it's just for me....

No comments:

Post a Comment

Comments welcome, but they are expected to be civil.
Please don't bother spamming me. I'm only going to delete it.