Git: Difference between revisions

From London Hackspace Wiki
(Remove excess whitespace.)
No edit summary
Line 1: Line 1:
For version control of the IRC bot scripts we use [http://en.wikipedia.org/wiki/Git_%28software%29 git]. To contribute to the scripts accessible via robonaut (the bot), you'll need an account on Babbage.
For version control of the IRC bot scripts we use [http://en.wikipedia.org/wiki/Git_%28software%29 git]. To contribute to projects such as the scripts accessible via robonaut (the bot), you'll need an account on Babbage.  We use Github for all common projects at Hackspace.


== First time config ==
== First time config ==


Before you can start committing to the git repository, you need to configure your account on babbage appropriately.
Before you can start committing to the git repository, you need to configure your account on Babbage:


  * '''git config --global user.name "Jane Doe"''' # This will set your name in git.
  git config --global user.name "Jane Doe"
  * '''git config --global user.email foo@test.com''' # This sets your email address.
  git config --global user.email jane@example.com
mkdir ~/git
 
This will update your ~/.gitconfig with the appropriate values, and is enough to make commits. You only need to do this once.
 
In order to contribute, you can then create a key for secure communication with Github:
 
ssh-keygen -f ~/git/key
cat ~/git/key.pub
 
On Github, create a new entry in '''SSH Private Keys''' in '''Account Settings''', and paste the output of the last command into the '''Key''' area.  You can also add the email address used above, and Github will automatically associate your commits with your account.
 
== For each project ==
 
The best way to contribute to a project with distributed version is to create your own copy, and then push upstream any changes you make.
 
To create a copy of the project:
 
cd ~/git
git clone git://github.com/londonhackspace/irccat-commands
cd irccat-commands


This only needs to be ran once. Once done, you can jump straght to the next section.


== Committing ==
== Committing ==


First of all, create and edit the files as per usual. Now, to see to it that they're committed to the repo, do the following:
First of all, create and edit the files as per usual. Now, to see to it that they're committed to the repo, do the following:
  * '''git add file1 file2 file3''' # This tells git which files you want to commit the changes for. You can always get an overview of what files have changed since the last commit by running '''git status'''.
 
  * '''git commit -m "A useful, but short, message on the changes"''' # This actually commits these changes, and attaches the comment after -m to the change to make it easy to see what changes you made at a glance.
  git add file1.sh file2*.py data/file3.txt
 
This tells git which files you want to commit the changes for. You can always get an overview of what files have changed since the last commit by running '''git status'''.
 
  git commit -m "A useful, but short, message on the changes"
 
This actually commits these changes, and attaches the comment after -m to the change to make it easy to see what changes you made at a glance. If you want to make a longer message, leave out -m, and you will be given a file in <code>vi</code> to edit.
 
Check your commit history using:
 
git log
 
<!--
 
 
== If you've done it in place ==
 


Now, you'll need to switch to the root user on babbage. As root:
Now, you'll need to switch to the root user on babbage. As root:
  * '''git push''' #  This makes your changes available on the github repository, and thus available to others.
  * '''git push''' #  This makes your changes available on the github repository, and thus available to others.
-->

Revision as of 23:21, 25 February 2011

For version control of the IRC bot scripts we use git. To contribute to projects such as the scripts accessible via robonaut (the bot), you'll need an account on Babbage. We use Github for all common projects at Hackspace.

First time config

Before you can start committing to the git repository, you need to configure your account on Babbage:

git config --global user.name "Jane Doe"
git config --global user.email jane@example.com
mkdir ~/git

This will update your ~/.gitconfig with the appropriate values, and is enough to make commits. You only need to do this once.

In order to contribute, you can then create a key for secure communication with Github:

ssh-keygen -f ~/git/key
cat ~/git/key.pub

On Github, create a new entry in SSH Private Keys in Account Settings, and paste the output of the last command into the Key area. You can also add the email address used above, and Github will automatically associate your commits with your account.

For each project

The best way to contribute to a project with distributed version is to create your own copy, and then push upstream any changes you make.

To create a copy of the project:

cd ~/git
git clone git://github.com/londonhackspace/irccat-commands
cd irccat-commands


Committing

First of all, create and edit the files as per usual. Now, to see to it that they're committed to the repo, do the following:

git add file1.sh file2*.py data/file3.txt

This tells git which files you want to commit the changes for. You can always get an overview of what files have changed since the last commit by running git status.

git commit -m "A useful, but short, message on the changes"

This actually commits these changes, and attaches the comment after -m to the change to make it easy to see what changes you made at a glance. If you want to make a longer message, leave out -m, and you will be given a file in vi to edit.

Check your commit history using:

git log