Nothing Special   »   [go: up one dir, main page]

Git Class Cheat Sheet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Git Cheat Sheet

Documentation (http://progit.org/book/)
git help [cmd]

Branching & Merging


List: Create: Checkout: Back: Merge: Create: Delete: git branch git branch testing git checkout testing # work, make some commits git checkout master git merge testing git checkout -b new-branch git branch -d new-branch

For SVN Users


Tracking Projects git clone url svn checkout url git pull svn update Create Repository git init svnadmin create repo git add . svn import file://repo git commit Files git add file git rm file git mv file Committing git commit -a Browsing git log git blame file git diff svn add file svn rm file svn mv file svn commit svn log | less svn blame file svn diff | less

Managing Remotes
Clone: List: Send: Recv: Add: Fetch: Checkout: git git git git git git git git git clone url remote -v push push origin master pull pull origin master remote add name url fetch name checkout name/master

3 Principles
1. (Almost) everything is local 2. Git commits are snapshots 3. Branching is cheap, use it often

Next Steps
git tag name git rebase commit git cherry-pick commit git bisect git-svn hooks tracking branches submodules interactive staging squashing commits repository hosting patches via email gitjour

Getting Started
Setup Install: Name: Email: sudo port install git-core +svn git config global user.name \ "Nate Murray" git config global user.email \ "nate@xcombinator.com"

First Repo cd mkdir -p projects/demo cd projects/demo git init git status ls -a echo "version 1" > test.txt git status git add test.txt git status git commit -m "added version one" git status Aliases st: git config global alias.st status ci: git config global alias.ci commit ca: git config global alias.ca commit -a

$Revision: 1.1, $Date: August 31, 2010 Nate Murray (nmurray@xcombinator.com) See also: http://book.git-scm.com/ http://git.or.cz/course/svn.html Based on Steve Taylons Clojure Cheat Sheet

GUI
Commits: Merge: gitx git mergetool -t opendiff

Internals
View Log: Show: Cat: git log git show a8dn3 # sha git cat-file -p 9s2j # sha

You might also like