CommunityData:Git: Difference between revisions

From CommunityData
No edit summary
Line 1: Line 1:
== Introduction ==
== Setting Up Git ==
 
Once you've installed git, there are some configuration options which will make your life much easier. You can set them globally with the following commands:
 
git config --global alias.spull '!__git_spull() { git pull "$@" && git submodule sync --recursive && git submodule update --init --recursive; }; __git_spull'
git config --global status.submoduleSummary true
 
These two commands will ensure that git works a little better with submodules. Submodules are essentially git repositories that are buried inside other git repositories. For example, the <code>wikiresearch</code> repository currently uses the <code>RCommunityData</code> repository as a submodule. If you're working in a wiki like this, you'll want to use <code>git spull</code> instead of just <code>git pull</code> which will also check for and pull changes made in any of your submodules.
 
== Gitolite Server ==


We have a private git server which uses [http://gitolite.com/gitolite/index.html gitolite] to manage permissions for git repositories.
We have a private git server which uses [http://gitolite.com/gitolite/index.html gitolite] to manage permissions for git repositories.


== Dependencies ==
=== Dependencies ===


To get started, you will need a [https://help.github.com/articles/generating-ssh-keys/ public SSH key]. You can send your public key (usually ~/.ssh/id_rsa.pub) to a current administrator (probably Mako), and they can add you as a new user.
To get started, you will need a [https://help.github.com/articles/generating-ssh-keys/ public SSH key]. You can send your public key (usually ~/.ssh/id_rsa.pub) to a current administrator (probably Mako), and they can add you as a new user.
Line 9: Line 18:
You will also need to have git installed.
You will also need to have git installed.


== Cloning a repository ==
=== Cloning a repository ===


"Cloning" a repository downloads the files, as well as the history, of a repository. It also creates a new git instance in that directory, so that you can commit changes to the code.
"Cloning" a repository downloads the files, as well as the history, of a repository. It also creates a new git instance in that directory, so that you can commit changes to the code.


== Creating a new repository ==
To clone a repository, run the following command:
 
  git clone --recursive git@code.communitydata.cc:''REPOSITORY_NAME''
 
=== Creating a new repository ===


To create a new repository, you will need to have admin rights. Currently, the administrators are Nate, Jeremy, Aaron, Mako, Sayamindu, and Jim. If you'd like to be an administrator, you should contact one of them!
To create a new repository, you will need to have admin rights. Currently, the administrators are Nate, Jeremy, Aaron, Mako, Sayamindu, and Jim. If you'd like to be an administrator, you should contact one of them!


=== Details for Administrators ===
=== Details for Administrators ===
==== Creating new repositories ====


If you are all already administrator, this describes how you will create a new repository.
If you are all already administrator, this describes how you will create a new repository.
Line 54: Line 68:
</source>
</source>


== Adding new users ==
==== Adding new users ====


To add new users, simply add their public key to the <code>keydir/</code> directory, renamed as <code>username.pub</code>
To add new users, simply add their public key to the <code>keydir/</code> directory, renamed as <code>username.pub</code>. The persons username (as called in the <code>code/gitolite.conf</code> file) will be whatever the username in the filename above is.

Revision as of 18:26, 25 July 2017

Setting Up Git

Once you've installed git, there are some configuration options which will make your life much easier. You can set them globally with the following commands:

git config --global alias.spull '!__git_spull() { git pull "$@" && git submodule sync --recursive && git submodule update --init --recursive; }; __git_spull'
git config --global status.submoduleSummary true

These two commands will ensure that git works a little better with submodules. Submodules are essentially git repositories that are buried inside other git repositories. For example, the wikiresearch repository currently uses the RCommunityData repository as a submodule. If you're working in a wiki like this, you'll want to use git spull instead of just git pull which will also check for and pull changes made in any of your submodules.

Gitolite Server

We have a private git server which uses gitolite to manage permissions for git repositories.

Dependencies

To get started, you will need a public SSH key. You can send your public key (usually ~/.ssh/id_rsa.pub) to a current administrator (probably Mako), and they can add you as a new user.

You will also need to have git installed.

Cloning a repository

"Cloning" a repository downloads the files, as well as the history, of a repository. It also creates a new git instance in that directory, so that you can commit changes to the code.

To clone a repository, run the following command:

 git clone --recursive git@code.communitydata.cc:REPOSITORY_NAME

Creating a new repository

To create a new repository, you will need to have admin rights. Currently, the administrators are Nate, Jeremy, Aaron, Mako, Sayamindu, and Jim. If you'd like to be an administrator, you should contact one of them!

Details for Administrators

Creating new repositories

If you are all already administrator, this describes how you will create a new repository.

First, you will need to clone the gitolite-admin repository

$ git clone git@code.communitydata.cc:gitolite-admin

And then edit the file conf/gitolite.conf. To add a new project, simply create a new entry at the bottom of the file.

For example,

repo foo
    RW+ = aaron mako
    R   = jdfoote

would create a new repository at git@code.communitydata.cc:foo with aaron and mako as admins, and give jdfoote read-only access *once this file was saved, committed, and pushed*.

You could then go to wherever the files are that you would like to track, and add this repository as a remote, like so:

$ cd foo
$ git init
$ git remote add origin git@code.communitydata.cc:foo
$ git add ./ # Adding everything to be tracked in git
$ git commit 
$ git push --set-upstream origin master

If this project already exists in git, then it's even easier. Just change the remote, and push it.

$ git remote set-url origin git@code.communitydata.cc:foo
$ git push

Adding new users

To add new users, simply add their public key to the keydir/ directory, renamed as username.pub. The persons username (as called in the code/gitolite.conf file) will be whatever the username in the filename above is.