Random Notes to Self on Git

You probably shouldn’t read this. Go to http://gitcasts.com/, http://git-scm.com/book/en/Getting-Started or http://gitref.org/ instead.

Basics

To list all of your personal git config settings

$ git config --list

To commit (assuming changes were staged first via “git add Name-of-File”):

$ git commit -m 'some notes, description of changes here'

To commit while adding all changes to all files at the same time:

$ git commit -am 'some notes, description of changes here'

To create and switch to a new branch

$ git checkout -b Your-New-Branch-Name

To switch to another branch:

$ git checkout Your-Branch-Name
$ git checkout master

To add current directory’s files, folders & subfolders to the Index, navigate to this dir and:

$ git ls-files --stage

Git with a Remote Server

To upload committed changes to remote server (codebase)

$ git push origin Name-of-Your-Branch-Here  

To copy your public SSH key to OSX’s clipboard (assuming you saved in the default location):

$ pbcopy < /Users/Your-User-Name-Here/.ssh/id_rsa.pub

Once public SSH key in clipboard, go to your remote Git server, like YourDomain.codebasehq.com, and paste it on the My Profile page.

To overwrite all local “YourBranchName” branch files with latest from origin/YourBranchName

$ git fetch origin
$ git reset --hard origin/YourBranchName