Monday, March 15, 2010

Gitosis Remote Repository Cheat Sheet

I've found myself looking up how to do various operations on remote gitosis repositories recently, so I decided to create myself a cheat sheet. My remote repositories are on Debian systems, so the users and other configuration options are those that you get when you do a stock install of gitosis on a Debian system. Most of this is shamelessly stolen from Garry Dolley's “Hosting Git repositories, The Easy (and Secure) Way” with slight adaptations for the Debian differences. The idea is to cover the specific commands you need to deal with Debian remote gitosis repositories. This intentially doesn't cover anything that you can figure out from just doing “man git” and digging in.

Creating a new local repository from a remote repository

There is a remote repository that you don't have locally, and you want to get a copy to work on.

git clone gitosis@<server>:<repository>.git
cd <repository>

Note that the admin repository is gitosis-admin.

Setting up the remote origin on a new (non-clone) local repository

You are creating a new repository on the remote server. You have edited the gitosis-admin configuration files appropriately and pushed the changes, and performed

git init

on the local directory to create a new local repository, but the remote and local repositories are not yet connected.

git remote add origin gitosis@<server>:<repository>.git

Pushing a new local repository to the remote repository for the first time

I must admit this command seems more complicated than it should need to be. But at least you only need to do this once per repository.

git push origin master:refs/heads/master

Updated 2012-07-30: yes, it is too complicated. For some time I've been using this shorter version:

git push origin master

No comments:

Post a comment