Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    gitosis: how to add new repository

    20th February 2009

    I assume that you already have your gitosis-admin repository working (this is described elsewhere).

    1. cd gitosis-admin && git pull – enter your gitosis administrative repository and ensure it is up-to-date
    2. $EDITOR gitosis.conf
    3. 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

    4. 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
    5. git commit -am ‘new repository: newreponame’; git push;
    6. 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.
    7. 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’
    8. git remote add origin ssh://gitosis@yourGitosisServerName/newreponame.git
    9. git push ––all
    10. 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/master

      Without these lines, you won’t be able to git pull.

    Share

    16 Responses to “gitosis: how to add new repository”

    1. hauptmech Says:

      Thanks, this was useful

    2. John E Says:

      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!

    3. Bogdan Says:

      You are welcome!

      I’m using this as a reference myself :)

    4. Synesthesia Says:

      [...] gitosis: how to add new repository [...]

    5. BigBaaadBob Says:

      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

    6. Bogdan Says:

      Thank you, I’ve updated the text.

    7. Marcin Says:

      Hi, thanks for sharing this information, got stuck following different site and followed your explanation and it all worked. Bookmarked :-).. cheers

    8. noqqe.de » Blog Archive » Gitosis | Debugging, Undokumentiertes und Konfiguration Says:

      [...] 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 [...]

    9. Slobo Says:

      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

    10. Bogdan Says:

      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.

    11. Slobo Says:

      I like to create an empty repo and connect it to project tracking software before making actual commits :)
      Cheers

    12. dinh vi gps Says:

      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 :D
      Thanks again!

    13. Bogdan Says:

      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 :)

    14. 將目前的 git 專案放到遠端主機上 « 傑克達與瑞兒絲的大小事 Says:

      [...] 注意: 這項操作需要先在 git server 的 gitosis 裏正確設定存取權限,不然一定會出現 access denied 而無法正確將本地端資料放到遠端,可參考這篇說明 [...]

    15. Damian Says:

      To concatenate commands and avoid possible mistakes replace ; with &&

      Thanks!

    16. Bogdan Says:

      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.

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>