Difference between revisions of "Git"
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 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. | 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. | ||
− | + | <!-- From here should probably be in a Git tutorial page... --> | |
== First time config == | == First time config == | ||
Line 13: | Line 13: | ||
In order to contribute, you can then create a key for secure communication with Github: | In order to contribute, you can then create a key for secure communication with Github: | ||
− | ssh-keygen | + | ssh-keygen |
− | cat ~/ | + | |
+ | Press return when it asks you for the filename. If it then asks you to overwrite, say no ('''n'''). | ||
+ | |||
+ | cat ~/.ssh/id_rsa.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. | 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. | ||
Line 68: | Line 71: | ||
git push github | git push github | ||
+ | |||
+ | <!--... to here --> | ||
+ | == Pull requests == | ||
+ | |||
+ | Pull requests are the easiest way to get your changes into the main repository. Simply visit the main repository, and click on the '''Pull request''' button | ||
<!-- | <!-- |
Revision as of 00:20, 26 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
Press return when it asks you for the filename. If it then asks you to overwrite, say no (n).
cat ~/.ssh/id_rsa.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. You can see what's changed by running:
git status
or
git diff
Now, to see to it that they're committed to the repo, do something like the following:
git add file1.sh data/file2.txt git add file3*.py
This tells git which files you want to commit the changes for. Finally, use:
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.
You should then check your commit history using:
git log
Pushing
To push your changes to Github, from where you can share them, you need to do a little bit more set-up. First, fork the original project from Github to your own account. Then tell git where it is:
git remote add github git@github.com:jane/irccat-commands
You can check this using:
git remote -v
Then whenever you need to push, you can just issue this command:
git push github
Pull requests
Pull requests are the easiest way to get your changes into the main repository. Simply visit the main repository, and click on the Pull request button