A little bit of git (a short github tutorial)

I generate loads of code, and back up very little, so an easy to use versioning system like github seems like a no-brainer.

Setting up a repo is a little tricky if there are some things you don’t want to track (and there almost always will be). Getting the account open is fairly easy — so i’m not going to cover that here.

The official create-a-repo tutorial is fairly good, so i’m just going to add a few points where I found things a little tricky.

To begin, select the ‘Repositories’ tab, and hit the green ‘New’ button.

Screen Shot 2013-04-21 at 8.09.56 PM

My first hint is: DO NOT initialise the repo with a README file.  This will create problems later.  If you make this mistake, follow these instructions to delete the repo and start again.

Screen Shot 2013-04-21 at 8.11.16 PM

My second hint is to include a .gitignore file. To do this, before starting to add files to the index, you’ll want to create a .gitignore file.

$ cd newRepo
$ touch .gitignore
$ vi .gitignore

I wanted to exclude data (*.RData), and picture (*.pdf and *.png) files, so i added these. My .gitignore file looks like this:

Screen Shot 2013-04-21 at 8.30.05 PM

Next, follow the steps listed on the site to finalise the repo — adding the README etc.

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/ricardianambivalence/newRepo.git
git push -u origin master

You can now proceed to git add files (git add file.r) and folders (git add ./misc/) and commit them as above — comfortable in the knowledge that the files you do not wish to have tracked are left untracked (this is particularly relevant where you are git adding folders).

This entry was posted in coding and tagged . Bookmark the permalink.

1 Response to A little bit of git (a short github tutorial)

  1. Pingback: Github for work and play (multiple accounts) | ricardian ambivalence

please comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.