Skip to content
Sean Anderson edited this page Jun 17, 2013 · 35 revisions

A brief set of instructions for working with Git locally

There are lots of tutorials out there and hard to pick one good one. Here are a bunch:
http://sixrevisions.com/resources/git-tutorials-beginners/

And here are bookmarks I've found useful about git:
https://pinboard.in/search/u:seananderson?query=git

Here's one good one I remember:
http://rogerdudler.github.io/git-guide/

To work with GitHub you'll need to do this first: https://help.github.com/articles/generating-ssh-keys

You'll also want to make sure your .gitconfig file matches your GitHub account: https://help.github.com/articles/setting-your-email-in-git

Then clone the link at the top of the main site. For example,
git clone git@github.com:seananderson/ss3sim.git

Then edit files.

Note that all future lines expect you to be somewhere within the main folder. I.e. somewhere within "ss3sim" or a subfolder.

If there are any new files then add them:

git add R/my-new-file.r

If I'm committing everything at once, I usually commit with this:

git commit -av

The -a means commit everything that's changed, even if I haven't added changed file with 'git add'. Drop the a if you only want to commit what you've manually added with git add. The -v means 'verbose', which helps to see all the changes you will commit.

Once you've committed all your changes, push your changes to the server:

git push

Oh, and before working you'll want to get in the habit of pulling any changes:

git pull

I use this as my cheat sheet for branching:
http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

And for anything fancy I end up Googling it.