<?xml version="1.0" encoding="UTF-8"?>
<guide>
  <body>&lt;h3&gt;Git principles&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://eagain.net/articles/git-for-computer-scientists/&quot; title=&quot;lots of pictures&quot;&gt;Git for computer scientists.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.kernel.org/pub/software/scm/git/docs/user-manual.html&quot;&gt;Git user&amp;#8217;s manual&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www-cs-students.stanford.edu/~blynn/gitmagic/&quot;&gt;Git Magic&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Zach Rusin&amp;#8217;s &lt;a href=&quot;http://zrusin.blogspot.com/2007/09/git-cheat-sheet.html&quot;&gt;Git Cheat Sheet&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;span class=&quot;caps&quot;&gt;SVG&lt;/span&gt; is at:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg&quot;&gt;http://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Sample png&amp;#8217;s are here:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png&quot;&gt;http://ktown.kde.org/&lt;span&gt;~&lt;/span&gt;zrusin/git/git-cheat-sheet-medium.png&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png&quot;&gt;http://ktown.kde.org/&lt;span&gt;~&lt;/span&gt;zrusin/git/git-cheat-sheet-large.png&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;cheat.errtheblog.com&lt;/h3&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://cheat.errtheblog.com/s/git/&quot;&gt;http://cheat.errtheblog.com/s/git/&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://cheat.errtheblog.com/s/git_usage/&quot;&gt;http://cheat.errtheblog.com/s/git_usage/&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://cheat.errtheblog.com/s/gitsvn/&quot;&gt;http://cheat.errtheblog.com/s/gitsvn/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;A Practical Git &lt;span class=&quot;caps&quot;&gt;GUIDE&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;(credit: notes extracted from &lt;span class=&quot;caps&quot;&gt;GIT&lt;/span&gt; screencast at http://www.peepcode.com.)&lt;/p&gt;
&lt;h3&gt;&lt;span class=&quot;caps&quot;&gt;CONFIGURE&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;identify yourself to git: email and your name&lt;/p&gt;
git config &amp;#8212;global user.name &amp;#8220;David Beckwith&amp;#8221;
git config &amp;#8212;global user.email &amp;#8220;dbitsolutions@gmail.com&amp;#8221;
&lt;p&gt;To view all options:&lt;/p&gt;
git config &amp;#8212;list
&lt;p&gt;OR&lt;/p&gt;
cat .gitconfig
&lt;h4&gt;&lt;span class=&quot;caps&quot;&gt;SET&lt;/span&gt; UP &lt;span class=&quot;caps&quot;&gt;ALIASES&lt;/span&gt;&lt;/h4&gt;
git config &amp;#8212;global alias.co checkout
&lt;h4&gt;&lt;span class=&quot;caps&quot;&gt;VIEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CONFIGURATION&lt;/span&gt;&lt;/h4&gt;
cat .gitconfig
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;IGNORE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WHITESPACE&lt;/span&gt; (Ruby is whitespace insensitive)&lt;/h4&gt;
git config &amp;#8212;global apply.whitespace nowarn
&lt;p&gt;Some nice aliases:&lt;/p&gt;
gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status
&lt;h3&gt;&lt;span class=&quot;caps&quot;&gt;START&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;USING&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;GIT&lt;/span&gt;&lt;/h3&gt;
git init
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;IGNORE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SOME&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FILES&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)&lt;/p&gt;
*.log
db/schema.rb
db/schema.sql
&lt;p&gt;Git automatically ignores empty directories. If you want to have a &lt;code&gt;log/&lt;/code&gt; directory, but want to ignore all the files in it, add the following lines to the root &lt;code&gt;.gitignore&lt;/code&gt;: (lines beginning with &amp;#8216;!&amp;#8217; are exceptions)&lt;/p&gt;
log/*
!.gitignore
&lt;p&gt;Then add an empty &lt;code&gt;.gitignore&lt;/code&gt; in the empty directory:&lt;/p&gt;
touch log/.gitignore
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;SCHEDULE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ADDITION&lt;/span&gt; OF &lt;span class=&quot;caps&quot;&gt;ALL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FILES&lt;/span&gt; TO &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;NEXT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMIT&lt;/span&gt;&lt;/h4&gt;
git add .
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;SEE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;STATUS&lt;/span&gt;&lt;/h4&gt;
git status
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;COMMIT&lt;/span&gt;&lt;/h4&gt;
git commit -m &amp;#8220;First import&amp;#8221;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;SEE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WHAT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;HAS&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BEEN&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMITTED&lt;/span&gt;&lt;/h4&gt;
git ls-files
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;SCHEDULE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;DELETION&lt;/span&gt; OF A &lt;span class=&quot;caps&quot;&gt;FILE&lt;/span&gt;&lt;/h4&gt;
git rm [file name]
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;COMMIT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ALL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CHANGES&lt;/span&gt; IN &lt;span class=&quot;caps&quot;&gt;FILES&lt;/span&gt; IN &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CURRENT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt;&lt;/h4&gt;
git commit -a
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;SCHEDULE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ADDITION&lt;/span&gt; OF AN &lt;span class=&quot;caps&quot;&gt;INDIVIDUAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FILE&lt;/span&gt; TO &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;NEXT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMIT&lt;/span&gt;&lt;/h4&gt;
git add [file name]
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;VIEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;DIFFERENCE&lt;/span&gt; AS &lt;span class=&quot;caps&quot;&gt;YOU&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMIT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;USE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; -v &lt;span class=&quot;caps&quot;&gt;OPTION&lt;/span&gt;&lt;/h4&gt;
git commit -v
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;COMMIT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;AND&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;TYPE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;MESSAGE&lt;/span&gt; ON &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMAND&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LINE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;USE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; -m &lt;span class=&quot;caps&quot;&gt;OPTION&lt;/span&gt;&lt;/h4&gt;
git commit -m &amp;#8220;This is the message describing the commit&amp;#8221;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;COMMIT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;AND&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;GET&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;AUTOMATICALLY&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ANY&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CHANGES&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;OTHER&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;PEOPLE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;USE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; -a &lt;span class=&quot;caps&quot;&gt;OPTION&lt;/span&gt;&lt;/h4&gt;
git commit -a
&lt;h4&gt;&lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;NORMAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMIT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMAND&lt;/span&gt;:&lt;/h4&gt;
git commit -a -v
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;VIEW&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;LOG&lt;/span&gt; OF &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMITS&lt;/span&gt;&lt;/h4&gt;
git log
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;VIEW&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;LOG&lt;/span&gt; OF &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMITS&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WITH&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;GRAPH&lt;/span&gt; TO &lt;span class=&quot;caps&quot;&gt;SHOW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;EXTENT&lt;/span&gt; OF &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CHANGES&lt;/span&gt;&lt;/h4&gt;
git log &amp;#8212;stat
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;HAVE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;PAGINATION&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WHEN&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;VIEWING&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOG&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FILE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;USE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; -v &lt;span class=&quot;caps&quot;&gt;OPTION&lt;/span&gt;&lt;/h4&gt;
git log -v
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;VISUALIZE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CHANGES&lt;/span&gt;&lt;/h4&gt;
gitk &amp;#8212;all
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;CREATE&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;NEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;TAG&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;AND&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;PUSH&lt;/span&gt; IT ON &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;&lt;/h4&gt;
git tag &amp;#8220;v1.3&amp;#8221;
git push &amp;#8212;tags
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;CREATE&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;NEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;&lt;/h4&gt;
git branch [name of your new branch]
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;PUSH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;NEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; TO A &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt;&lt;/h4&gt;
git push origin [new-remote]
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;PULL&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;NEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FROM&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt;&lt;/h4&gt;
git fetch origin [remote-branch]:[new-local-branch]
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;VIEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ALL&lt;/span&gt; OF &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;EXISTING&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCHES&lt;/span&gt;&lt;/h4&gt;
git branch
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;VIEW&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;LIST&lt;/span&gt; OF &lt;span class=&quot;caps&quot;&gt;ALL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCHES&lt;/span&gt;&lt;/h4&gt;
git branch -a
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;SWITCH&lt;/span&gt; TO &lt;span class=&quot;caps&quot;&gt;ANOTHER&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;The state of your file system will change after executing this command.&lt;/p&gt;
git checkout [name of the branch you want to switch to]
&lt;p&gt;OR&lt;/p&gt;
git co [name of the branch you want to switch to]
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;MAKE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SURE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THAT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;NEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;GETS&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CHANGES&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;MASTER&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; (&lt;span class=&quot;caps&quot;&gt;WHERE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;EVERYBODY&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ELSE&lt;/span&gt; IS &lt;span class=&quot;caps&quot;&gt;WORKING&lt;/span&gt;) &lt;span class=&quot;caps&quot;&gt;USE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REBASE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMAND&lt;/span&gt;&lt;/h4&gt;
git rebase master
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;MERGE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;NEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;INTO&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;MASTER&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;First, switch back to the master branch:&lt;/p&gt;
git co master
&lt;p&gt;Check to see what changes you&amp;#8217;re about to merge together, compare the two branches:&lt;/p&gt;
git diff master xyz
&lt;p&gt;If you&amp;#8217;re in a branch that&amp;#8217;s not the &lt;code&gt;xyz&lt;/code&gt; branch and want to merge the &lt;code&gt;xyz&lt;/code&gt; branch into it:&lt;/p&gt;
git merge xyz
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;REVERT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CHANGES&lt;/span&gt; to before the merge.&lt;/h4&gt;
git reset &amp;#8212;hard ORIG_HEAD
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;RESOLVE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CONFLICTS&lt;/span&gt; just edit your file.&lt;/h4&gt;
&lt;p&gt;Remove the markings, add the file, then commit.&lt;/p&gt;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;CREATE&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;AND&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SWITCH&lt;/span&gt; TO &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; IN &lt;span class=&quot;caps&quot;&gt;ONE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;MOVE&lt;/span&gt;:&lt;/h4&gt;
git checkout -b [name of new branch]
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;CREATE&lt;/span&gt; A &amp;#8220;&lt;span class=&quot;caps&quot;&gt;CLIPBOARD&lt;/span&gt;&amp;#8221; or &amp;#8220;&lt;span class=&quot;caps&quot;&gt;STASH&lt;/span&gt;&amp;#8221; OF &lt;span class=&quot;caps&quot;&gt;CHANGES&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THAT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ARE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YET&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;COMMITED&lt;/span&gt; (SO &lt;span class=&quot;caps&quot;&gt;THAT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOU&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CAN&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SWITCH&lt;/span&gt; TO &lt;span class=&quot;caps&quot;&gt;ANOTHER&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; IN &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;MIDDLE&lt;/span&gt; OF &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CHANGES&lt;/span&gt;.), &lt;span class=&quot;caps&quot;&gt;CREATE&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;STASH&lt;/span&gt;.&lt;/h4&gt;
git stash &amp;#8220;Put a message here to remind you of what you&amp;#8217;re saving to the clipboard&amp;#8221;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;SWITCH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;AWAY&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CURRENT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;&lt;/h4&gt;
git co [branch you want to switch to]
&lt;p&gt;Do whatever&lt;br /&gt;
Then switch back to the stashed branch&lt;/p&gt;
git co [the stashed branch]
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;VIEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LIST&lt;/span&gt; OF &lt;span class=&quot;caps&quot;&gt;STASHES&lt;/span&gt;&lt;/h4&gt;
git stash list
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;LOAD&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BACK&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &amp;#8220;&lt;span class=&quot;caps&quot;&gt;CLIPBOARD&lt;/span&gt;&amp;#8221; OR &amp;#8220;&lt;span class=&quot;caps&quot;&gt;STASH&lt;/span&gt;&amp;#8221;&lt;/h4&gt;
git stash apply
&lt;p&gt;Now you can continue to work where you were previously.&lt;/p&gt;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;DELETE&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THAT&lt;/span&gt; IS &lt;span class=&quot;caps&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;USED&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ANYMORE&lt;/span&gt;, but already merged into the current branch.  (TO &lt;span class=&quot;caps&quot;&gt;CLEAN&lt;/span&gt; UP)&lt;/h4&gt;
git branch -d [name of branch you want to delete]
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;DELETE&lt;/span&gt; AN &lt;span class=&quot;caps&quot;&gt;UNMERGED&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;&lt;/h4&gt;
git branch -D [name of branch you want to delete]
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;DELETE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;STASH&lt;/span&gt;.  (&lt;span class=&quot;caps&quot;&gt;ERASE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &amp;#8220;&lt;span class=&quot;caps&quot;&gt;CLIPBOARD&lt;/span&gt;&amp;#8221; &lt;span class=&quot;caps&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;MEMORY&lt;/span&gt;)&lt;/h4&gt;
git stash clear
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;SET&lt;/span&gt; UP &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FOR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SHARING&lt;/span&gt; ON A &lt;span class=&quot;caps&quot;&gt;CENTRAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SERVER&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Copy up your repository. e.g.:&lt;/p&gt;
scp -r my_project deploy@yourbox.com:my_project
&lt;p&gt;Move your files on the remote server to &lt;code&gt;/var/git/my_project&lt;/code&gt;&lt;br /&gt;
For security make the owner of this project git&lt;br /&gt;
On the repository server:&lt;/p&gt;
sudo chown -R git:git my_project
&lt;p&gt;Then (for security) restrict the &amp;#8220;deploy&amp;#8221; user to doing git-related things in &lt;code&gt;/etc/passwd&lt;/code&gt; with a &lt;code&gt;git-shell&lt;/code&gt;.&lt;/p&gt;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;CHECK&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;OUT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;GIT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt; TO &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCALHOST&lt;/span&gt;.  ON &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;HOST&lt;/span&gt; DO &lt;span class=&quot;caps&quot;&gt;THIS&lt;/span&gt;:&lt;/h4&gt;
git clone git@yourbox.com:/var/git/my_project
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;SEE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SOME&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;INFO&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ABOUT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THAT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WILL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;TELL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOU&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WHICH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt; IS &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;MASTER&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;AND&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WHICH&lt;/span&gt; IS &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SLAVE&lt;/span&gt;:&lt;/h4&gt;
cat .git/config
&lt;p&gt;By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.&lt;/p&gt;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SERVER&lt;/span&gt;:&lt;/h4&gt;
git pull
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;GET&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;COPY&lt;/span&gt; OF &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ENTIRE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt; (e.g. a repository named &amp;#8220;laptop&amp;#8221;) &lt;span class=&quot;caps&quot;&gt;WITHOUT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;MERGING&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THEM&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;INTO&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCHES&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;USE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FETCH&lt;/span&gt;&lt;/h4&gt;
git fetch laptop
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;MERGE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;TWO&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCHES&lt;/span&gt; (ie. your local xyz branch with your local master branch) &lt;span class=&quot;caps&quot;&gt;USE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;MERGE&lt;/span&gt;&lt;/h4&gt;
git merge laptop/xyz
&lt;p&gt;This merged the (already copied laptop repository&amp;#8217;s xyz branch) with the current branch you&amp;#8217;re sitting in.&lt;/p&gt;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;MERGE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WITH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THAT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOU&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ARE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SITTING&lt;/span&gt; IN &lt;span class=&quot;caps&quot;&gt;USE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;PULL&lt;/span&gt;&lt;/h4&gt;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;ADD&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;KNOWLEDGE&lt;/span&gt; (TO &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt;) OF A 2ND &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt;, &lt;span class=&quot;caps&quot;&gt;LIKE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LAPTOP&lt;/span&gt;&lt;/h4&gt;
git remote add laptop duo2book.local:repos/m_project
&lt;p&gt;where &amp;#8217;&amp;#8217;&amp;#8217;laptop&amp;#8217;&amp;#8217;&amp;quot; is the name of the remote repository and  &amp;#8220;&amp;#8216;&amp;#8217;duo2book.local&amp;#8217;&amp;#8217;&amp;#8221; is the name of the remote machine.&lt;/p&gt;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;VIEW&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;META&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;INFORMATION&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ABOUT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THAT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt;&lt;/h4&gt;
git remote show laptop
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;PUSH&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;COMMITTED&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;CHANGE&lt;/span&gt; OF &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; xyz &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; TO &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; laptop &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;&lt;/h4&gt;
git push laptop xyz
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;CREATE&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;TRACKING&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt; (A &lt;span class=&quot;caps&quot;&gt;SLAVE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;).  Ie. to link a local branch to a remote branch:&lt;/h4&gt;
git branch &amp;#8212;track local_branch remote_branch
&lt;h4&gt;&lt;span class=&quot;caps&quot;&gt;NOW&lt;/span&gt; IF YOU&amp;#8217;RE &lt;span class=&quot;caps&quot;&gt;SITTING&lt;/span&gt; IN &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;TRACKING&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;, TO &lt;span class=&quot;caps&quot;&gt;PULL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOU&lt;/span&gt; DON&amp;#8217;T &lt;span class=&quot;caps&quot;&gt;NEED&lt;/span&gt; TO &lt;span class=&quot;caps&quot;&gt;SPECIFY&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;TRACKING&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;:&lt;/h4&gt;
git  pull
&lt;p&gt;Note: You can track(link) different local branches to different remote machines.  For example, you can track your friend&amp;#8217;s &amp;#8220;upgrade&amp;#8221; branch with your &amp;#8220;bobs_upgrade&amp;#8221; branch, and simultaneously you can track the origin&amp;#8217;s &amp;#8220;master&amp;#8221; branch (of your main webserver) with your local &amp;#8220;master&amp;#8221; branch.&lt;/p&gt;
&lt;p&gt;By convention, &amp;#8216;origin&amp;#8217; is the local name given to the remote centralized server which is the way &lt;span class=&quot;caps&quot;&gt;SVN&lt;/span&gt; is usually set up on a remote server.&lt;/p&gt;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;SEE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WHICH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCHES&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;ARE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;TRACKING&lt;/span&gt; A &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BRANCH&lt;/span&gt;:&lt;/h4&gt;
git remote show origin
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;WORK&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WITH&lt;/span&gt; AN &lt;span class=&quot;caps&quot;&gt;SVN&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;BUT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WORK&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;WITH&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;GIT&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCALLY&lt;/span&gt;:&lt;/h4&gt;
git-svn clone [http location of an svn repository]
&lt;p&gt;Now you can work with the checked out directory as though it was a git repository.  (cuz it is)&lt;/p&gt;
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;PUSH&lt;/span&gt; (&lt;span class=&quot;caps&quot;&gt;COMMIT&lt;/span&gt;) &lt;span class=&quot;caps&quot;&gt;CHANGES&lt;/span&gt; TO &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REMOTE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SERVER&lt;/span&gt;&lt;/h4&gt;
git-svn dcommit
&lt;h4&gt;TO &lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;YOUR&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;SVN&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;REPOSITORY&lt;/span&gt;&lt;/h4&gt;
git-svn rebase
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;NOTE&lt;/span&gt;: make sure you have your perl bindings to your local svn installation.&lt;/p&gt;
&lt;h4&gt;I screwed up, how do I reset my checkout?&lt;/h4&gt;
git checkout -f</body>
  <created-at type="datetime">2008-04-18T09:17:49-07:00</created-at>
  <id type="integer">41</id>
  <permalink>git-cheat-sheet</permalink>
  <title>Git Cheat Sheet</title>
  <updated-at type="datetime">2009-10-19T16:59:09-07:00</updated-at>
  <user-id type="integer">141533</user-id>
</guide>
