(another good quick reference I've found is Git - SVN Crash Course and Git_Guide (sourcemage) )
To setup git for windows... see gitcasts.com Git on Windows
- download and install msysGit from http://git.or.cz/
To setup github account
- sign up for account
- create ssh public-private key which is needed to push changes to git hub...
- > ssh-keygen -C 'emailaddress@host' -t rsa
- key is stored in %HOME%\.ssh directory on windows
- copy and paste public key to github
To setup git user name and email
- > git config --global user.name 'Greg Houston'
- > git config --global user.emal 'my_emal@host'
To see global configuration
- > cat ~/.gitconfig
To start a new project
- change to project root directory
- > git init
- the command above creates the .git directory
To set a list of files to ignore
- create .gitignore in the project directory
- in .gitignore list files or glob patterns to ignore (can use ** and * and ?, e.g. tmp/**/*)
To see files in git repository
- > git ls-files
To see status of files/commits/staged/etc
- > git status
To remove an existing file
- use git rm instead of the operating system's delete or rm...
- > git rm filename_or_pattern
- > git commit -m "description of changes"
To add and commit files
- first add files to the index of files to commit...
- > git add filename_or_pattern
- added files are called "staged" because they are ready to be committed (git add does put an object to the git repository)
- next commit the changes, use -m to provide a comment
- > git commit -m "description of changes"
- you must add all changed files before commit will do anything.
To automatically add and commit modified files
- > git commit -a -m "description of changes"
To see information about commits
- > git log
To see commits with diff...
- > git log -p
To clone repository (ex. from github)
- > git clone git://github.com/ghouston/color-console.git
To push changes to a remote repository
- git gui will just sit there, i guess it is waiting on the passphrase
- > git push git@github.com:ghouston/color-console.git master
- where "master" is the name of the branch
- it will prompt for the ssh key's passphrase
To rename a file
- to avoid loosing history information, you need to commit the rename before modifying the renamed file!
- > git mv oldfilename newfilename
- commit the newfilename before modifying it!
To create a branch
- > git branch dev
To list branches (* by working branch)
- > git branch
To select a branch to work with
- > git checkout dev
- or (the following is works best on Ubuntu)
- > git checkout -b local_branch_name --track remote_branch_name
To diff changes between branches
- > git diff dev master
To update branch with changes from base
- > git checkout dev
- > git rebase master
To push branch to remote
- > git push git@github.com:ghouston/tofuhash.git dev
To merge branches (e.g. dev into master)
- > git checkout master
- > git merge dev
To work on an upstream branch that isn't master (next in this example)
- git checkout --track -b next origin/next
- git pull
For more details see http://github.com/guides/git-cheat-sheet