0% found this document useful (0 votes)
634 views

Git Class Cheat Sheet

This document provides a summary of common Git commands organized into the following sections: Branching & Merging, For SVN Users, Managing Remotes, 3 Principles, Next Steps, Getting Started, GUI, and Internals. It includes brief explanations and examples for essential tasks such as cloning repositories, checking out branches, committing changes, and resolving merges.

Uploaded by

Chiech An Tai
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
634 views

Git Class Cheat Sheet

This document provides a summary of common Git commands organized into the following sections: Branching & Merging, For SVN Users, Managing Remotes, 3 Principles, Next Steps, Getting Started, GUI, and Internals. It includes brief explanations and examples for essential tasks such as cloning repositories, checking out branches, committing changes, and resolving merges.

Uploaded by

Chiech An Tai
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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 \ "[email protected]"

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 ([email protected]) 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