Git Quick Reference Guide

Create git repository: cd /path/to/repo && git init

Checkout a repositoy: git clone user@host:/path/to/repo

Change branch: git checkout -b [branchname]

Add files to local copy of repository: git add [filename] # can use wildcards

List files in local repository: git ls-tree --full-tree -r HEAD

Commit changes to local repository: git commit -am "Message"

Push changes to existing remote repo: git push origin master

Push changes to new remote repo: git remote add origin username@host

Tagging commits (e.g, software releases): git log && git tag [tag] [commit-id]

Replace local borked file with remote copy: git checkout -- [filename]

Reset local repo with remote: git fetch origin && git reset --hard origin/master

Colorize git output: git config color.ui true

 

Sources:
http://gitready.com/ (Beginner Sections)

http://rogerdudler.github.io/git-guide/

http://stackoverflow.com/questions/8533202/list-files-in-local-git-repo

About these ads