Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (31 sloc) 2.84 KB

Using git

These are just some random notes about git — I need to add more in this section later as we start to develop some ideas about how to best use it. Most of this is cribbed from Scott Chacon’s git in one hour webcast.

Creating a Repository

There are two ways to create a repository:

  • clone it from an exitsing repo

  • run "git commit -m 'initial commit'"

  • use "git status" to get a status of working changes

  • use "git log" to get a log file of all commits

  • "git show" shows what the last commit was

Adding Files

Next, you need to add files using "git add <filename>"

More commit options

Then you use "git commit -m 'some message'" to commit the changes You can also used "git add <filename>" to stage your commits, which means that you can commit in different groups. this is helpful if you want to create a clear audit trail of what you were doing.

  • To just commit everything, you can use "git commit -a"

  • To commit stuff in steps, use "git add <filename>"


git encourages you to do lots of little stuff inside branches, not just big stuff. For example, you might create a new branch to resolve a ticket, fix it in the branch, and then merge it back in later. This is called a "topic branch".

The command to see a branch is called "git branch".

You can make a new branch using "git branch test" to create a new branch. To work in the branch, you do "git checkout test".

You can make any changes you want in the directory, and all changes happen in just that branch. So, you can add files, make new changes, or whatever, and they’ll happen in only that one place. Changes are saved at each commit.

If you want to move back to another branch, all you have to do it check it back out and the files will look just as they did at the last commit point.

You can view all the activity in the branches using "gitk". This will pop up a ltille browser to go through all the changes on the branch you’re on. You can use "gitk --all" to see the changes across all branches.


I need to review this section, but merging basically collapses two branches into a single branch. You can then remove the topic branches using "git branch -d branch name" (double check this syntax)

You do something to add a remote server

You can then use "git fetch" to pull off some remote copy of the repository, but moves it into your repo as a separate branch. This way you can inspect what someone else is doing, but not mess up your own work, which is really pretty cool. You then merge that brach back in as you see fit.

Comparing versions of files

Use "git diff" to see the differences between the current version of the repo and the new verion. You can use "git diff | mate" to see the diff visualized in textmate, which is pretty cool.

Incorporating changes from contributors