gitosis: how to add new repository
20th February 2009
I assume that you already have your gitosis-admin repository working (this is described elsewhere).
- cd gitosis-admin && git pull – enter your gitosis administrative repository and ensure it is up-to-date
- $EDITOR gitosis.conf
- add [group newreponame] section (newreponame is the name of your new repository being added); add yourself with members = yourlogin@yourhost line; also add writable = newreponame line:
[group newreponame]
members = yourlogin@yourhost
writable = newreponame - based on my assumption of a correctly setup gitosis-admin repository, you should already have the appropriate public key in the keydir directory, but if not – copy your user’s ssh public key to keydir in the form of yourlogin@yourhostname.pub, then do git add keydir/yourlogin@yourhostname.pub
- git commit -am ‘new repository: newreponame’; git push;
- now that you have the new repo permissions configured, let’s actually create it. Navigate to the directory holding the files of your project (e.g. cd ~/newreponame), and do git init; git add . – this initializes empty git repository, and then adds all the files to it. If you have no files – you can skip the ‘git add .’ command, as it will do nothing for you.
- git commit -m ‘initial commit’. If you had no files added to the commit, git will complain that it cannot create an empty commit. In this case use the command git commit ––allow-empty -m ‘initial commit’
- git remote add origin ssh://gitosis@yourGitosisServerName/newreponame.git
- git push ––all
- final thing: git config ––add branch.master.remote origin && git config ––add branch.master.merge refs/heads/master; alternatively, cd .git && $EDITOR config, and then add these lines:
[branch "master"]
remote = origin
merge = refs/heads/masterWithout these lines, you won’t be able to git pull.
April 17th, 2009 at 7:00
Thanks, this was useful
October 13th, 2009 at 17:35
Thanks!! I love gitosis but always forget the details. The previous guides I use always seem to leave one step out or another, added to my bookmarks!
October 13th, 2009 at 23:18
You are welcome!
I’m using this as a reference myself
January 14th, 2010 at 0:27
[...] gitosis: how to add new repository [...]
January 22nd, 2010 at 0:02
Rather than directly edit the config file, you can (and maybe should) use:
$ git config --add branch.master.remote origin
$ git config --add branch.master.merge refs/heads/master
January 25th, 2010 at 10:13
Thank you, I’ve updated the text.
July 12th, 2010 at 11:10
Hi, thanks for sharing this information, got stuck following different site and followed your explanation and it all worked. Bookmarked :-).. cheers
August 12th, 2010 at 20:48
[...] Definierbare Rechte und Gruppenorganisation für Git-Repositories. Im Web findet man unzählige How-To’s die eine Standardinstallation wirklich gut und übersichtlich dokumentieren bzw. dazu [...]
September 15th, 2011 at 21:11
In a recent git version I needed to substitute
7. git commit –allow-empty -m “Initial commit”
otherwise I get greeted with a message that there is nothing to commit
September 16th, 2011 at 9:46
I believe you had no files in the directory where you ‘git init; git add .’ (or you haven’t run ‘git add .’, which is less likely).
I’ll update the post to mention this case, thanks.
September 18th, 2011 at 23:39
I like to create an empty repo and connect it to project tracking software before making actual commits
Cheers
December 31st, 2011 at 21:43
Thanks for your instructions,
It works like a charm
But at when I clone new project, add a file, commit new file, then push back to the server it throw errors
After edit new project config file, change: bare = false => true, it work normally
Thanks again!
January 2nd, 2012 at 18:10
By default gitosis should create bare repositories. If that was not your case – then either something went wrong when setting up gitosis, or you’re not using gitosis at all
April 18th, 2012 at 10:29
[...] 注æ„: é€™é …æ“作需è¦å…ˆåœ¨ git server çš„ gitosis è£æ£ç¢ºè¨å®šå˜å–權é™ï¼Œä¸ç„¶ä¸€å®šæœƒå‡ºç¾ access denied 而無法æ£ç¢ºå°‡æœ¬åœ°ç«¯è³‡æ–™æ”¾åˆ°é 端,å¯åƒè€ƒé€™ç¯‡èªªæ˜Ž [...]
April 30th, 2012 at 22:20
To concatenate commands and avoid possible mistakes replace ; with &&
Thanks!
May 1st, 2012 at 16:38
Right, this is what I’ve used in half of the commands. Should have probably used in all commands, but ‘;’ is one symbol faster to type than ‘&&’ Still a valid point, thanks.