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: (Beginner Sections)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s