Editing CommunityData:Git
From CommunityData
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
== 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: | 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: | ||
Line 26: | Line 6: | ||
git config --global status.submoduleSummary true | 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 | 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 [ | We have a private git server which uses [http://gitolite.com/gitolite/index.html gitolite] to manage permissions for git repositories. | ||
=== 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. | |||
You will also need to have git installed. | |||
=== Cloning a repository === | === Cloning a repository === | ||
Line 46: | Line 24: | ||
To clone a repository, run the following command: | To clone a repository, run the following command: | ||
git clone --recursive git@code.communitydata. | 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! | |||
=== Creating | === 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 | First, you will need to clone the gitolite-admin repository | ||
$ git clone git@code.communitydata. | $ git clone git@code.communitydata.cc:gitolite-admin | ||
And then edit the file <code>conf/gitolite.conf</code>. To add a new project, simply create a new entry at the bottom of the file. | And then edit the file <code>conf/gitolite.conf</code>. To add a new project, simply create a new entry at the bottom of the file. | ||
Line 68: | Line 49: | ||
</source> | </source> | ||
would create a new repository at git@code.communitydata. | 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: | You could then go to wherever the files are that you would like to track, and add this repository as a remote, like so: | ||
<source lang='bash'> | <source lang='bash'> | ||
$ cd foo | $ cd foo | ||
$ git remote add origin git@code.communitydata. | $ git init | ||
$ git push --set-upstream origin | $ 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 | |||
</source> | </source> | ||
Line 89: | Line 64: | ||
<source lang='bash'> | <source lang='bash'> | ||
$ git remote set-url origin git@code.communitydata. | $ git remote set-url origin git@code.communitydata.cc:foo | ||
$ git push | $ git push | ||
</source> | </source> | ||
Line 97: | Line 72: | ||
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. | 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. | ||
== Using git-annex | ==== Using git-annex ==== | ||
{{note}} This is still experimental, and may go away. Don't put files in it without a backup. | {{note}} This is still experimental, and may go away. Don't put files in it without a backup. | ||
Git is not a very good system for managing large files, which is a problem for us, since we often have large data files. Enter [https://git-annex.branchable.com/walkthrough/ git-annex], a system that works in tandem with git and lets you store large files (but avoids using git as the data store). Our gitolite installation supports git-annex. To start using git-annex, install git-annex locally in your computer. Most GNU/Linux distributions has git-annex packages. Then, in your existing git repository execute the following initialization command: | |||
Git is not a very good system for managing large files, which is a problem for us, since we often have large data files. Enter [https://git-annex.branchable.com/walkthrough/ git-annex], a system that works in tandem with git and lets you store large files (but avoids using git as the data store). Our gitolite installation supports git-annex. To start using git-annex, install git-annex locally in your computer. Most GNU/Linux distributions | |||
Then, in your existing git repository execute the following initialization command: | |||
<source lang='bash'> | <source lang='bash'> | ||
Line 127: | Line 97: | ||
$ git annex copy --to origin | $ git annex copy --to origin | ||
</source> | </source> | ||
Once these commands are successful, your collaborators should be able to get the file with the following command (assuming that they have already run <code>git annex init</code>): | Once these commands are successful, your collaborators should be able to get the file with the following command (assuming that they have already run <code>git annex init</code>): | ||
<source lang='bash'> | <source lang='bash'> | ||
$ git annex get data/largedata.csv.bz2.gpg | $ git annex get data/largedata.csv.bz2.gpg | ||
</source> | </source> |