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
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 little browser that you can use 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
This section will address how to incorporate changes people make. I needs to cover both collaboratrs (people who have been invited to have write access) and people who fork it and do a pull request.
Using git in TextMate with the git bundle
The git bundle allows you to save stuff in git right from within TextMate. Not sure what this buys me yet, but here are the commands:
mkdir -p /Library/Application\ Support/TextMate/Bundles cd !$ git clone http://git.gitorious.org/git-tmbundle/mainline.git Git.tmbundle osascript -e 'tell app "TextMate" to reload bundles'
You’ll need to add a path variable to tell TextMate where git is installed. First, locate git:
$which git /usr/local/git/bin/git
Then go to "Preferences → Advanced" and click the "Shell Variables" tab. Then add a variable named "TM_GIT" and put in the path to git you found on the last step.