.. vim: syntax=rst .. include:: ../global.rst .. _vcs-git: ======================= Set up a git repository ======================= There are a couple ways to setup a git repository depending on what type of work you are trying to do. #. Single repository which is used by you and no one else #. Group repository which is used by you and someone else in your group #. Public repository which is readable (and clonable) by anyone Single ====== To setup a single repository, you can simply change to the directory which you want to be under git control and do the following:: git init git add . git commit -m "Initial import" This will give you a git repository which you can then clone remotely using ssh. .. _group-repository: Group ===== To setup a group repository, you will need to use a directory which is readable/writable by all the members of your group. This can usually be found in your center or program shared storage. You will need to initialize a bare shared group repository. The following example is assuming your shared storage is at ``/org/centers/foo`` and your project name is *bar*:: GIT_DIR=bar.git git init --bare --shared=group Initialized empty shared Git repository in /org/centers/foo/repos/private/bar.git/ You can now clone your new repository by doing the following:: git clone /org/centers/foo/repos/private/bar Initialized empty Git repository in /tmp/bar/.git/ warning: You appear to have cloned an empty repository. You can now begin adding things to the ``bar`` directory and committing them. When you are ready to push your changes to the central repository, you can do:: git push --all Counting objects: 3, done. Writing objects: 100% (3/3), 235 bytes, done. Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. To /org/centers/foo/repos/private/bar * [new branch] master -> master As you can see, the ``--all`` created the remote *master* branch for you. In the future, all you will need to do is ``git push``. .. note:: You can determine your group membership by using the ``id`` command on any Oden Institute machine. Your *gid* is your primary group and the other groups listed are supplementary groups to which you have been added based on your affiliation.