CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Wed, 23 Jul 2025 20:48:48 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20090216155538
location: https://web.archive.org/web/20090216155538/https://github.com/guides/git-cheat-sheet.atom
server-timing: captures_list;dur=1.547990, exclusion.robots;dur=0.025639, exclusion.robots.policy;dur=0.011032, esindex;dur=0.016492, cdx.remote;dur=51.911680, LoadShardBlock;dur=582.195891, PetaboxLoader3.datanode;dur=434.738269, PetaboxLoader3.resolve;dur=134.130744
x-app-server: wwwb-app219
x-ts: 302
x-tr: 669
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app219; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Wed, 23 Jul 2025 20:48:49 GMT
content-type: application/atom+xml; charset=utf-8
content-length: 398620
x-archive-orig-server: nginx/0.6.26
x-archive-orig-date: Mon, 16 Feb 2009 15:55:37 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-x-runtime: 2837ms
x-archive-orig-etag: "d6477fbcbf91068b770ce5619cc7a042"
x-archive-orig-cache-control: private, max-age=0, must-revalidate
x-archive-orig-content-length: 398620
cache-control: max-age=1800
x-archive-guessed-content-type: text/xml
x-archive-guessed-charset: utf-8
memento-datetime: Mon, 16 Feb 2009 15:55:38 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Wed, 17 Dec 2008 13:32:49 GMT", ; rel="prev memento"; datetime="Wed, 17 Dec 2008 13:32:49 GMT", ; rel="memento"; datetime="Mon, 16 Feb 2009 15:55:38 GMT", ; rel="next memento"; datetime="Sat, 25 Sep 2010 05:14:16 GMT", ; rel="last memento"; datetime="Sat, 25 Sep 2010 05:14:16 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_8_20090216150520_crawl100-c/52_8_20090216155305_crawl101.arc.gz
server-timing: captures_list;dur=0.430739, exclusion.robots;dur=0.015128, exclusion.robots.policy;dur=0.006981, esindex;dur=0.009516, cdx.remote;dur=38.862245, LoadShardBlock;dur=654.556226, PetaboxLoader3.datanode;dur=611.746829, PetaboxLoader3.resolve;dur=124.780647, load_resource;dur=161.940390
x-app-server: wwwb-app219
x-ts: 200
x-tr: 895
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
accept-ranges: bytes
tag:github.com,2008:/guides/git-cheat-sheet
GitHub Guides - Git Cheat Sheet
2009-02-09T22:37:47-08:00
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2009-02-09T22:37:47-08:00
Git Cheat Sheet - version 37
Mon Feb 09 22:37:47 -0800 2009
<h3>Git principles</h3>
<p><a href="https://eagain.net/articles/git-for-computer-scientists/" title="lots of pictures">Git for computer scientists.</a></p>
<p><a href="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git user’s manual</a></p>
<p><a href="https://www-cs-students.stanford.edu/~blynn/gitmagic/">Git Magic</a></p>
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span></h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES</span></h4>
<p>Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)</p>
<pre><code>*.log
db/schema.rb
db/schema.sql</code></pre>
<p>Git automatically ignores empty directories. If you want to have a <code>log/</code> directory, but want to ignore all the files in it, first add <code>log/*</code> in <code>.gitignore</code>, then add an empty <code>.gitignore</code> in the empty directory:</p>
<pre><code>touch log/.gitignore</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span></h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE THE STATUS</span></h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span></h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span></h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span></h4>
<pre><code>git rm [file name]</code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span></h4>
<pre><code>git add [file name]</code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span></h4>
<pre><code>git branch [name of your new branch]</code></pre>
<h4><span class="caps">TO PUSH THE NEW BRANCH TO A REMOTE REPOSITORY</span></h4>
<pre><code>git push origin [new-remote]</code></pre>
<h4><span class="caps">TO PULL A NEW BRANCH FROM A REMOTE REPOSITORY</span></h4>
<pre><code>git fetch origin [remote-branch]:[new-local-branch]</code></pre>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span></h4>
<p>The state of your file system will change after executing this command.</p>
<pre><code>git checkout [name of the branch you want to switch to]</code></pre>
<p>OR </p>
<pre><code>git co [name of the branch you want to switch to]</code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span></h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span></h4>
<p>First, switch back to the master branch:</p>
<pre><code>git co master</code></pre>
<p>Check to see what changes you’re about to merge together, compare the two branches:</p>
<pre><code>git diff master xyz</code></pre>
<p>If you’re in a branch that’s not the <code>xyz</code> branch and want to merge the <code>xyz</code> branch into it:</p>
<pre><code>git merge xyz</code></pre>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b [name of new branch]</code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co [branch you want to switch to]</code></pre>
<p>Do whatever
Then switch back to the stashed branch</p>
<pre><code>git co [the stashed branch]</code></pre>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<p>Now you can continue to work where you were previously.</p>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<p>Copy up your repository. e.g.:</p>
<pre><code>scp -r my_project deploy@yourbox.com:my_project</code></pre>
<p>Move your files on the remote server to <code>/var/git/my_project</code>
For security make the owner of this project git
On the repository server:</p>
<pre><code>sudo chown -R git:git my_project</code></pre>
<p>Then (for security) restrict the “deploy” user to doing git-related things in <code>/etc/passwd</code> with a <code>git-shell</code>.</p>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<p>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<p>This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</p>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<p>where ’’‘laptop’’” is the name of the remote repository and ”’‘duo2book.local’’” is the name of the remote machine.</p>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TO PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track local_branch remote_branch</code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<p>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</p>
<p>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</p>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone [http location of an svn repository]</code></pre>
<p>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</p>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<p><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</p>
<h4>I screwed up, how do I reset my checkout?</h4>
<pre><code>git checkout -f</code></pre>
dandv
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2009-01-20T03:15:27-08:00
Git Cheat Sheet - version 36
Tue Jan 20 03:15:27 -0800 2009
<h3>Git principles</h3>
<p><a href="https://eagain.net/articles/git-for-computer-scientists/" title="lots of pictures">Git for computer scientists.</a></p>
<p><a href="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git user’s manual</a></p>
<p><a href="https://www-cs-students.stanford.edu/~blynn/gitmagic/">Git Magic</a></p>
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span></h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES</span></h4>
<p>Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)</p>
<pre><code>*.log
db/schema.rb
db/schema.sql</code></pre>
<p>Git automatically ignores empty directories. If you want e.g. and <code>log/</code> directory, but want to ignore all the files in it, first add <code>log/*</code> in <code>.gitignore</code>, then add an empty <code>.gitignore</code> in the empty directory:</p>
<pre><code>touch log/.gitignore</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span></h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE WHAT THE STATUS</span></h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span></h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span></h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span></h4>
<pre><code>git rm [file name]</code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span></h4>
<pre><code>git add [file name]</code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span></h4>
<pre><code>git branch [name of your new branch]</code></pre>
<h4><span class="caps">TO PUSH THE NEW BRANCH TO A REMOTE REPOSITORY</span></h4>
<pre><code>git push origin [new-remote]</code></pre>
<h4><span class="caps">TO PULL A NEW BRANCH FROM A REMOTE REPOSITORY</span></h4>
<pre><code>git fetch origin [remote-branch]:[new-local-branch]</code></pre>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span></h4>
<p>The state of your file system will change after executing this command.</p>
<pre><code>git checkout [name of the branch you want to switch to]</code></pre>
<p>OR </p>
<pre><code>git co [name of the branch you want to switch to]</code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span></h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span></h4>
<p>First, switch back to the master branch:</p>
<pre><code>git co master</code></pre>
<p>Check to see what changes you’re about to merge together, compare the two branches:</p>
<pre><code>git diff master xyz</code></pre>
<p>If you’re in a branch that’s not the <code>xyz</code> branch and want to merge the <code>xyz</code> branch into it:</p>
<pre><code>git merge xyz</code></pre>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b [name of new branch]</code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co [branch you want to switch to]</code></pre>
<p>Do whatever
Then switch back to the stashed branch</p>
<pre><code>git co [the stashed branch]</code></pre>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<p>Now you can continue to work where you were previously.</p>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<p>Copy up your repository. e.g.:</p>
<pre><code>scp -r my_project deploy@yourbox.com:my_project</code></pre>
<p>Move your files on the remote server to <code>/var/git/my_project</code>
For security make the owner of this project git
On the repository server:</p>
<pre><code>sudo chown -R git:git my_project</code></pre>
<p>Then (for security) restrict the “deploy” user to doing git-related things in <code>/etc/passwd</code> with a <code>git-shell</code>.</p>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<p>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<p>This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</p>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<p>where ’’‘laptop’’” is the name of the remote repository and ”’‘duo2book.local’’” is the name of the remote machine.</p>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TO PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track local_branch remote_branch</code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<p>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</p>
<p>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</p>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone [http location of an svn repository]</code></pre>
<p>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</p>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<p><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</p>
<h4>I screwed up, how do I reset my checkout?</h4>
<pre><code>git checkout -f</code></pre>
koblo
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2009-01-20T03:12:51-08:00
Git Cheat Sheet - version 35
Tue Jan 20 03:12:51 -0800 2009
<h3>Git principles</h3>
<p><a href="https://eagain.net/articles/git-for-computer-scientists/" title="lots of pictures">Git for computer scientists.</a></p>
<p><a href="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git user’s manual</a></p>
<p><a href="https://www-cs-students.stanford.edu/~blynn/gitmagic/">Git Magic</a></p>
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span></h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES</span></h4>
<p>Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)</p>
<pre><code>*.log
db/schema.rb
db/schema.sql</code></pre>
<p>Git automatically ignores empty directories. If you want e.g. and <code>log/</code> directory, but want to ignore all the files in it, first add <code>log/*</code> in <code>.gitignore</code>, then add an empty <code>.gitignore</code> in the empty directory:</p>
<pre><code>touch log/.gitignore</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span></h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE WHAT THE STATUS</span></h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span></h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span></h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span></h4>
<pre><code>git rm [file name]</code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span></h4>
<pre><code>git add [file name]</code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span></h4>
<pre><code>git branch [name of your new branch]</code></pre>
<h4><span class="caps">TO PUSH THE NEW BRANCH TO THE REMOTE REPOSITORY</span>
Checkout the branch you want to push.</h4>
<pre><code>git push origin <new-remote></code></pre>
<h4><span class="caps">TO PULL THE NEW BRANCH FROM REMOTE REPOSITORY</span>
Download a new branch from the remote repository and add it to your local repository.
“remote-branch” is the name of the remote branch you want’s to fetch.
“new-local-branch” is the name of the branch on your local repository.
Use the same name on you local repository if you wants to commit changes </h4>
<pre><code>git fetch origin <remote-branch>:<new-local-branch></code></pre>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span></h4>
<p>The state of your file system will change after executing this command.</p>
<pre><code>git checkout [name of the branch you want to switch to]</code></pre>
<p>OR </p>
<pre><code>git co [name of the branch you want to switch to]</code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span></h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span></h4>
<p>First, switch back to the master branch:</p>
<pre><code>git co master</code></pre>
<p>Check to see what changes you’re about to merge together, compare the two branches:</p>
<pre><code>git diff master xyz</code></pre>
<p>If you’re in a branch that’s not the <code>xyz</code> branch and want to merge the <code>xyz</code> branch into it:</p>
<pre><code>git merge xyz</code></pre>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b [name of new branch]</code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co [branch you want to switch to]</code></pre>
<p>Do whatever
Then switch back to the stashed branch</p>
<pre><code>git co [the stashed branch]</code></pre>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<p>Now you can continue to work where you were previously.</p>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<p>Copy up your repository. e.g.:</p>
<pre><code>scp -r my_project deploy@yourbox.com:my_project</code></pre>
<p>Move your files on the remote server to <code>/var/git/my_project</code>
For security make the owner of this project git
On the repository server:</p>
<pre><code>sudo chown -R git:git my_project</code></pre>
<p>Then (for security) restrict the “deploy” user to doing git-related things in <code>/etc/passwd</code> with a <code>git-shell</code>.</p>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<p>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<p>This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</p>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<p>where ’’‘laptop’’” is the name of the remote repository and ”’‘duo2book.local’’” is the name of the remote machine.</p>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TO PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track local_branch remote_branch</code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<p>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</p>
<p>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</p>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone [http location of an svn repository]</code></pre>
<p>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</p>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<p><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</p>
<h4>I screwed up, how do I reset my checkout?</h4>
<pre><code>git checkout -f</code></pre>
koblo
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2009-01-20T03:10:49-08:00
Git Cheat Sheet - version 34
Tue Jan 20 03:10:49 -0800 2009
<h3>Git principles</h3>
<p><a href="https://eagain.net/articles/git-for-computer-scientists/" title="lots of pictures">Git for computer scientists.</a></p>
<p><a href="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git user’s manual</a></p>
<p><a href="https://www-cs-students.stanford.edu/~blynn/gitmagic/">Git Magic</a></p>
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span></h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES</span></h4>
<p>Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)</p>
<pre><code>*.log
db/schema.rb
db/schema.sql</code></pre>
<p>Git automatically ignores empty directories. If you want e.g. and <code>log/</code> directory, but want to ignore all the files in it, first add <code>log/*</code> in <code>.gitignore</code>, then add an empty <code>.gitignore</code> in the empty directory:</p>
<pre><code>touch log/.gitignore</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span></h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE WHAT THE STATUS</span></h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span></h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span></h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span></h4>
<pre><code>git rm [file name]</code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span></h4>
<pre><code>git add [file name]</code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span></h4>
<pre><code>git branch [name of your new branch]</code></pre>
<h4><span class="caps">TO PUSH THE NEW BRANCH TO THE REMOTE REPOSITORY</span></h4>
<p>Checkout the branch you want to push
git push origin <new-remote></p>
<h4><span class="caps">TO PULL THE NEW BRANCH FROM REMOTE REPOSITORY</span>
Download a new branch from the remote repository and add it to your local repository</h4>
<pre><code>git fetch origin <remote-branch>:<new-local-branch></code></pre>
<p>the “remote-branch” is the name of the remote branch you want’s to fetch and “new-local-branch” is the name of the branch on your local repository. You should use the same name on you local repository if you wants to commit changes</p>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span></h4>
<p>The state of your file system will change after executing this command.</p>
<pre><code>git checkout [name of the branch you want to switch to]</code></pre>
<p>OR </p>
<pre><code>git co [name of the branch you want to switch to]</code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span></h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span></h4>
<p>First, switch back to the master branch:</p>
<pre><code>git co master</code></pre>
<p>Check to see what changes you’re about to merge together, compare the two branches:</p>
<pre><code>git diff master xyz</code></pre>
<p>If you’re in a branch that’s not the <code>xyz</code> branch and want to merge the <code>xyz</code> branch into it:</p>
<pre><code>git merge xyz</code></pre>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b [name of new branch]</code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co [branch you want to switch to]</code></pre>
<p>Do whatever
Then switch back to the stashed branch</p>
<pre><code>git co [the stashed branch]</code></pre>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<p>Now you can continue to work where you were previously.</p>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<p>Copy up your repository. e.g.:</p>
<pre><code>scp -r my_project deploy@yourbox.com:my_project</code></pre>
<p>Move your files on the remote server to <code>/var/git/my_project</code>
For security make the owner of this project git
On the repository server:</p>
<pre><code>sudo chown -R git:git my_project</code></pre>
<p>Then (for security) restrict the “deploy” user to doing git-related things in <code>/etc/passwd</code> with a <code>git-shell</code>.</p>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<p>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<p>This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</p>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<p>where ’’‘laptop’’” is the name of the remote repository and ”’‘duo2book.local’’” is the name of the remote machine.</p>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TO PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track local_branch remote_branch</code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<p>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</p>
<p>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</p>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone [http location of an svn repository]</code></pre>
<p>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</p>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<p><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</p>
<h4>I screwed up, how do I reset my checkout?</h4>
<pre><code>git checkout -f</code></pre>
koblo
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-10-17T18:11:12-07:00
Git Cheat Sheet - version 33
Fri Oct 17 18:11:12 -0700 2008
<h3>Git principles</h3>
<p><a href="https://eagain.net/articles/git-for-computer-scientists/" title="lots of pictures">Git for computer scientists.</a></p>
<p><a href="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git user’s manual</a></p>
<p><a href="https://www-cs-students.stanford.edu/~blynn/gitmagic/">Git Magic</a></p>
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span></h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES</span></h4>
<p>Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)</p>
<pre><code>*.log
db/schema.rb
db/schema.sql</code></pre>
<p>Git automatically ignores empty directories. If you want e.g. and <code>log/</code> directory, but want to ignore all the files in it, first add <code>log/*</code> in <code>.gitignore</code>, then add an empty <code>.gitignore</code> in the empty directory:</p>
<pre><code>touch log/.gitignore</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span></h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE WHAT THE STATUS</span></h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span></h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span></h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span></h4>
<pre><code>git rm [file name]</code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span></h4>
<pre><code>git add [file name]</code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span></h4>
<pre><code>git branch [name of your new branch]</code></pre>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span></h4>
<p>The state of your file system will change after executing this command.</p>
<pre><code>git checkout [name of the branch you want to switch to]</code></pre>
<p>OR </p>
<pre><code>git co [name of the branch you want to switch to]</code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span></h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span></h4>
<p>First, switch back to the master branch:</p>
<pre><code>git co master</code></pre>
<p>Check to see what changes you’re about to merge together, compare the two branches:</p>
<pre><code>git diff master xyz</code></pre>
<p>If you’re in a branch that’s not the <code>xyz</code> branch and want to merge the <code>xyz</code> branch into it:</p>
<pre><code>git merge xyz</code></pre>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b [name of new branch]</code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co [branch you want to switch to]</code></pre>
<p>Do whatever
Then switch back to the stashed branch</p>
<pre><code>git co [the stashed branch]</code></pre>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<p>Now you can continue to work where you were previously.</p>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<p>Copy up your repository. e.g.:</p>
<pre><code>scp -r my_project deploy@yourbox.com:my_project</code></pre>
<p>Move your files on the remote server to <code>/var/git/my_project</code>
For security make the owner of this project git
On the repository server:</p>
<pre><code>sudo chown -R git:git my_project</code></pre>
<p>Then (for security) restrict the “deploy” user to doing git-related things in <code>/etc/passwd</code> with a <code>git-shell</code>.</p>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<p>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<p>This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</p>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<p>where ’’‘laptop’’” is the name of the remote repository and ”’‘duo2book.local’’” is the name of the remote machine.</p>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TO PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track local_branch remote_branch</code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<p>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</p>
<p>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</p>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone [http location of an svn repository]</code></pre>
<p>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</p>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<p><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</p>
<h4>I screwed up, how do I reset my checkout?</h4>
<pre><code>git checkout -f</code></pre>
seven1m
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-10-03T18:02:36-07:00
Git Cheat Sheet - version 32
Fri Oct 03 18:02:36 -0700 2008
<h3>Git principles</h3>
<p><a href="https://eagain.net/articles/git-for-computer-scientists/" title="lots of pictures">Git for computer scientists.</a></p>
<p><a href="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git user’s manual</a></p>
<p><a href="https://www-cs-students.stanford.edu/~blynn/gitmagic/">Git Magic</a></p>
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span></h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES</span></h4>
<p>Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)</p>
<pre><code>*.log
db/schema.rb
db/schema.sql</code></pre>
<p>Git automatically ignores empty directories. If you want e.g. and <code>log/</code> directory, but want to ignore all the files in it, first add <code>log/*</code> in <code>.gitignore</code>, then add an empty <code>.gitignore</code> in the empty directory:</p>
<pre><code>touch log/.gitignore</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span></h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE WHAT THE STATUS</span></h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span></h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span></h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span></h4>
<pre><code>git rm [file name]</code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span></h4>
<pre><code>git add [file name]</code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span></h4>
<pre><code>git branch [name of your new branch]</code></pre>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span></h4>
<p>The state of your file system will change after executing this command.</p>
<pre><code>git checkout [name of the branch you want to switch to]</code></pre>
<p>OR </p>
<pre><code>git co [name of the branch you want to switch to]</code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span></h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span></h4>
<p>First, switch back to the master branch:</p>
<pre><code>git co master</code></pre>
<p>Check to see what changes you’re about to merge together, compare the two branches:</p>
<pre><code>git diff master xyz</code></pre>
<p>If you’re in a branch that’s not the <code>xyz</code> branch and want to merge the <code>xyz</code> branch into it:</p>
<pre><code>git merge xyz</code></pre>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b [name of new branch]</code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co [branch you want to switch to]</code></pre>
<p>Do whatever
Then switch back to the stashed branch</p>
<pre><code>git co [the stashed branch]</code></pre>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<p>Now you can continue to work where you were previously.</p>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<p>Copy up your repository. e.g.:</p>
<pre><code>scp -r my_project deploy@yourbox.com:my_project</code></pre>
<p>Move your files on the remote server to <code>/var/git/my_project</code>
For security make the owner of this project git
On the repository server:</p>
<pre><code>sudo chown -R git:git my_project</code></pre>
<p>Then (for security) restrict the “deploy” user to doing git-related things in <code>/etc/passwd</code> with a <code>git-shell</code>.</p>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<p>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<p>This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</p>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<p>where ’’‘laptop’’” is the name of the remote repository and ”’‘duo2book.local’’” is the name of the remote machine.</p>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TO PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track <a href="remote name of branch">local name of branch</a></code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<p>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</p>
<p>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</p>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone [http location of an svn repository]</code></pre>
<p>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</p>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<p><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</p>
<h4>I screwed up, how do I reset my checkout?</h4>
<pre><code>git checkout -f</code></pre>
cursethemartyr
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-09-07T07:45:32-07:00
Git Cheat Sheet - version 31
Sun Sep 07 07:45:32 -0700 2008
<h3>Git principles</h3>
<p><a href="https://eagain.net/articles/git-for-computer-scientists/" title="lots of pictures">Git for computer scientists.</a></p>
<p><a href="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git user’s manual</a></p>
<p><a href="https://www-cs-students.stanford.edu/~blynn/gitmagic/">Git Magic</a></p>
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span></h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES</span></h4>
<p>Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)</p>
<pre><code>*.log
db/schema.rb
db/schema.sql</code></pre>
<p>Git automatically ignores empty directories. If you want e.g. and <code>log/</code> directory, but want to ignore all the files in it, first add <code>log/*</code> in <code>.gitignore</code>, then add an empty <code>.gitignore</code> in the empty directory:</p>
<pre><code>touch log/.gitignore</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span></h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE WHAT THE STATUS</span></h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span></h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span></h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span></h4>
<pre><code>git rm [file name]</code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span></h4>
<pre><code>git add [file name]</code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span></h4>
<pre><code>git branch [name of your new branch]</code></pre>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span></h4>
<p>The state of your file system will change after executing this command.</p>
<pre><code>git checkout [name of the branch you want to switch to]</code></pre>
<p>OR </p>
<pre><code>git co [name of the branch you want to switch to]</code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span></h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span></h4>
<p>First, switch back to the master branch:</p>
<pre><code>git co master</code></pre>
<p>Check to see what changes you’re about to merge together, compare the two branches:</p>
<pre><code>git diff master xyz</code></pre>
<p>If you’re in a branch that’s not the <code>xyz</code> branch and want to merge the <code>xyz</code> branch into it:</p>
<pre><code>git merge xyz</code></pre>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b [name of new branch]</code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co [branch you want to switch to]</code></pre>
<p>Do whatever
Then switch back to the stashed branch</p>
<pre><code>git co [the stashed branch]</code></pre>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<p>Now you can continue to work where you were previously.</p>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D [name of branch you want to delete]</code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<p>Copy up your repository. e.g.:</p>
<pre><code>scp -r my_project deploy@yourbox.com:my_project</code></pre>
<p>Move your files on the remote server to <code>/var/git/my_project</code>
For security make the owner of this project git
On the repository server:</p>
<pre><code>sudo chown -R git:git my_project</code></pre>
<p>Then (for security) restrict the “deploy” user to doing git-related things in <code>/etc/passwd</code> with a <code>git-shell</code>.</p>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<p>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<p>This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</p>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<p>where ’’‘laptop’’” is the name of the remote repository and ”’‘duo2book.local’’” is the name of the remote machine.</p>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track <a href="remote name of branch">local name of branch</a></code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<p>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</p>
<p>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</p>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone [http location of an svn repository]</code></pre>
<p>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</p>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<p><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</p>
<h4>I screwed up, how do I reset my checkout?</h4>
<pre><code>git checkout -f</code></pre>
why
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-17T23:53:07-07:00
Git Cheat Sheet - version 30
Sun Aug 17 23:53:07 -0700 2008
<h3>Git principles</h3>
<p><a href="https://eagain.net/articles/git-for-computer-scientists/" title="lots of pictures">Git for computer scientists.</a></p>
<p><a href="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git user’s manual</a></p>
<p><a href="https://www-cs-students.stanford.edu/~blynn/gitmagic/">Git Magic</a></p>
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span></h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES</span></h4>
<p>Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)</p>
<pre><code>*.log
db/schema.rb
db/schema.sql</code></pre>
<p>Git automatically ignores empty directories. If you want e.g. and <code>log/</code> directory, but want to ignore all the files in it, first add <code>log/*</code> in <code>.gitignore</code>, then add an empty <code>.gitignore</code> in the empty directory:</p>
<pre><code>touch log/.gitignore</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span></h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE WHAT THE STATUS</span></h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span></h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span></h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span></h4>
<pre><code>git rm <file name></code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span></h4>
<pre><code>git add <file name></code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span></h4>
<pre><code>git branch <name of your new branch></code></pre>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span></h4>
<p>The state of your file system will change after executing this command.</p>
<pre><code>git checkout <name of the branch you want to switch to></code></pre>
<p>OR </p>
<pre><code>git co <name of the branch you want to switch to></code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span></h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span></h4>
<p>First, switch back to the master branch:</p>
<pre><code>git co master</code></pre>
<p>Check to see what changes you’re about to merge together, compare the two branches:</p>
<pre><code>git diff master xyz</code></pre>
<p>If you’re in a branch that’s not the <code>xyz</code> branch and want to merge the <code>xyz</code> branch into it:</p>
<pre><code>git merge xyz</code></pre>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b <name of new branch></code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co <branch you want to switch to></code></pre>
<p>Do whatever
Then switch back to the stashed branch</p>
<pre><code>git co <the stashed branch></code></pre>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<p>Now you can continue to work where you were previously.</p>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d <name of branch you want to delete></code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D <name of branch you want to delete></code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<p>Copy up your repository. e.g.:</p>
<pre><code>scp -r my_project deploy@yourbox.com:my_project</code></pre>
<p>Move your files on the remote server to <code>/var/git/my_project</code>
For security make the owner of this project git
On the repository server:</p>
<pre><code>sudo chown -R git:git my_project</code></pre>
<p>Then (for security) restrict the “deploy” user to doing git-related things in <code>/etc/passwd</code> with a <code>git-shell</code>.</p>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<p>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<p>This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</p>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<p>where ’’‘laptop’’” is the name of the remote repository and ”’‘duo2book.local’’” is the name of the remote machine.</p>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track <local name of branch> <remote name of branch></code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<p>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</p>
<p>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</p>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone <http location of an svn repository></code></pre>
<p>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</p>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<p><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</p>
<h4>I screwed up, how do I reset my checkout?</h4>
<pre><code>git checkout -f</code></pre>
amiroff
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-12T11:28:55-07:00
Git Cheat Sheet - version 29
Tue Aug 12 11:28:55 -0700 2008
<h3>Git principles</h3>
<p><a href="https://eagain.net/articles/git-for-computer-scientists/" title="lots of pictures">Git for computer scientists.</a></p>
<p><a href="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git user’s manual</a></p>
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span></h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES</span></h4>
<p>Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)</p>
<pre><code>*.log
db/schema.rb
db/schema.sql</code></pre>
<p>Git automatically ignores empty directories. If you want e.g. and <code>log/</code> directory, but want to ignore all the files in it, first add <code>log/*</code> in <code>.gitignore</code>, then add an empty <code>.gitignore</code> in the empty directory:</p>
<pre><code>touch log/.gitignore</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span></h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE WHAT THE STATUS</span></h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span></h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span></h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span></h4>
<pre><code>git rm <file name></code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span></h4>
<pre><code>git add <file name></code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span></h4>
<pre><code>git branch <name of your new branch></code></pre>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span></h4>
<p>The state of your file system will change after executing this command.</p>
<pre><code>git checkout <name of the branch you want to switch to></code></pre>
<p>OR </p>
<pre><code>git co <name of the branch you want to switch to></code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span></h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span></h4>
<p>First, switch back to the master branch:</p>
<pre><code>git co master</code></pre>
<p>Check to see what changes you’re about to merge together, compare the two branches:</p>
<pre><code>git diff master xyz</code></pre>
<p>If you’re in a branch that’s not the <code>xyz</code> branch and want to merge the <code>xyz</code> branch into it:</p>
<pre><code>git merge xyz</code></pre>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b <name of new branch></code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co <branch you want to switch to></code></pre>
<p>Do whatever
Then switch back to the stashed branch</p>
<pre><code>git co <the stashed branch></code></pre>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<p>Now you can continue to work where you were previously.</p>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d <name of branch you want to delete></code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D <name of branch you want to delete></code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<p>Copy up your repository. e.g.:</p>
<pre><code>scp -r my_project deploy@yourbox.com:my_project</code></pre>
<p>Move your files on the remote server to <code>/var/git/my_project</code>
For security make the owner of this project git
On the repository server:</p>
<pre><code>sudo chown -R git:git my_project</code></pre>
<p>Then (for security) restrict the “deploy” user to doing git-related things in <code>/etc/passwd</code> with a <code>git-shell</code>.</p>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<p>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<p>This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</p>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<p>where ’’‘laptop’’” is the name of the remote repository and ”’‘duo2book.local’’” is the name of the remote machine.</p>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track <local name of branch> <remote name of branch></code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<p>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</p>
<p>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</p>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone <http location of an svn repository></code></pre>
<p>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</p>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<p><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</p>
<h4>I screwed up, how do I reset my checkout?</h4>
<pre><code>git checkout -f</code></pre>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-08T02:23:56-07:00
Git Cheat Sheet - version 28
Fri Aug 08 02:23:56 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span></h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES</span></h4>
<p>Add a file in the root directory called .gitignore and add some files to it: (comments begin with hash)</p>
<pre><code>*.log
db/schema.rb
db/schema.sql</code></pre>
<p>Git automatically ignores empty directories. If you want e.g. and <code>log/</code> directory, but want to ignore all the files in it, first add <code>log/*</code> in <code>.gitignore</code>, then add an empty <code>.gitignore</code> in the empty directory:</p>
<pre><code>touch log/.gitignore</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span></h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE WHAT THE STATUS</span></h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span></h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span></h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span></h4>
<pre><code>git rm <file name></code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span></h4>
<pre><code>git add <file name></code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span></h4>
<pre><code>git branch <name of your new branch></code></pre>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span></h4>
<p>The state of your file system will change after executing this command.</p>
<pre><code>git checkout <name of the branch you want to switch to></code></pre>
<p>OR </p>
<pre><code>git co <name of the branch you want to switch to></code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span></h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span></h4>
<p>First, switch back to the master branch:</p>
<pre><code>git co master</code></pre>
<p>Check to see what changes you’re about to merge together, compare the two branches:</p>
<pre><code>git diff master xyz</code></pre>
<p>If you’re in a branch that’s not the <code>xyz</code> branch and want to merge the <code>xyz</code> branch into it:</p>
<pre><code>git merge xyz</code></pre>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b <name of new branch></code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co <branch you want to switch to></code></pre>
<p>Do whatever
Then switch back to the stashed branch</p>
<pre><code>git co <the stashed branch></code></pre>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<p>Now you can continue to work where you were previously.</p>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d <name of branch you want to delete></code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D <name of branch you want to delete></code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<p>Copy up your repository. e.g.:</p>
<pre><code>scp -r my_project deploy@yourbox.com:my_project</code></pre>
<p>Move your files on the remote server to <code>/var/git/my_project</code>
For security make the owner of this project git
On the repository server:</p>
<pre><code>sudo chown -R git:git my_project</code></pre>
<p>Then (for security) restrict the “deploy” user to doing git-related things in <code>/etc/passwd</code> with a <code>git-shell</code>.</p>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<p>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<p>This merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</p>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<p>where ’’‘laptop’’” is the name of the remote repository and ”’‘duo2book.local’’” is the name of the remote machine.</p>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track <local name of branch> <remote name of branch></code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<p>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</p>
<p>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</p>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone <http location of an svn repository></code></pre>
<p>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</p>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<p><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</p>
<h4>I screwed up, how do I reset my checkout?</h4>
<pre><code>git checkout -f</code></pre>
hellekin
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-08T02:13:03-07:00
Git Cheat Sheet - version 27
Fri Aug 08 02:13:03 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<pre><code>git config --global user.name "David Beckwith"</code></pre>
<pre><code>git config --global user.email "dbitsolutions@gmail.com"</code></pre>
<p>To view all users:</p>
<pre><code>git config --list</code></pre>
<p>OR</p>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">SET UP ALIASES</span></h4>
<pre><code>git config --global alias.co checkout</code></pre>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<pre><code>cat .gitconfig</code></pre>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<pre><code>git config --global apply.whitespace nowarn</code></pre>
<p>Some nice aliases:</p>
<pre><code>gb = git branch</code></pre>
<pre><code>gba = git branch -a</code></pre>
<pre><code>gc = git commit -v</code></pre>
<pre><code>gd = git diff | mate</code></pre>
<pre><code>gl = git pull</code></pre>
<pre><code>gp = git push</code></pre>
<pre><code>gst = git status</code></pre>
<h3><span class="caps">START USING GIT</span>:</h3>
<pre><code>git init</code></pre>
<h4><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</h4>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</h4>
<pre><code>git add .</code></pre>
<h4><span class="caps">TO SEE WHAT THE STATUS</span>:</h4>
<pre><code>git status</code></pre>
<h4><span class="caps">TO COMMIT</span>:</h4>
<pre><code>git commit -m "First import"</code></pre>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</h4>
<pre><code>git ls-files</code></pre>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</h4>
<pre><code>git rm <file name></code></pre>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</h4>
<pre><code>git add <file name></code></pre>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git commit -v</code></pre>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<pre><code>git commit -m "This is the message describing the commit"</code></pre>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<pre><code>git commit -a</code></pre>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<pre><code>git commit -a -v</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<pre><code>git log</code></pre>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span> </h4>
<pre><code>git log --stat</code></pre>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<pre><code>git log -v</code></pre>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<pre><code>gitk --all</code></pre>
<h4><span class="caps">TO CREATE A NEW BRANCH</span>:</h4>
<pre><code>git branch <name of your new branch></code></pre>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<pre><code>git branch</code></pre>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<pre><code>git branch -a</code></pre>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</h4>
<pre><code>git checkout <name of the branch you want to switch to></code></pre>
<p>OR </p>
<pre><code>git co <name of the branch you want to switch to></code></pre>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:</h4>
<pre><code>git rebase master</code></pre>
<h4><span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.</h4>
<code> first switch back to the master branch.</code>
git co master
<code> check to see what changes you're about to merge together, compare the two branches:</code>
git diff master xyz
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
git merge xyz
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<pre><code>git reset --hard ORIG_HEAD</code></pre>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file. </h4>
<pre><code>Remove the markings, add the file, then commit.</code></pre>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<pre><code>git checkout -b <name of new branch></code></pre>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<pre><code>git stash "Put a message here to remind you of what you're saving to the clipboard"</code></pre>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<pre><code>git co <branch you want to switch to></code></pre>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
git co <the stashed branch>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<pre><code>git stash list</code></pre>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH” </h4>
<pre><code>git stash apply</code></pre>
<code> now you can continue to work where you were previously.</code>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<pre><code>git branch -d <name of branch you want to delete></code></pre>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span> </h4>
<pre><code>git branch -D <name of branch you want to delete></code></pre>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<pre><code>git stash clear</code></pre>
<h4><span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span></h4>
<code> Copy up your repository. e.g.:</code>
scp -r my_project deploy@yourbox.com:my_project
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
sudo chown -R git:git my_project
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<pre><code>git clone git@yourbox.com:/var/git/my_project</code></pre>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<pre><code>cat .git/config</code></pre>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<pre><code>git pull</code></pre>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<pre><code>git fetch laptop</code></pre>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<pre><code>git merge laptop/xyz</code></pre>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
<pre><code>git remote add laptop duo2book.local:repos/m_project</code></pre>
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<pre><code>git remote show laptop</code></pre>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<pre><code>git push laptop xyz</code></pre>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<pre><code>git branch --track <local name of branch> <remote name of branch></code></pre>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<pre><code>git pull</code></pre>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<pre><code>git remote show origin</code></pre>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<pre><code>git-svn clone <http location of an svn repository></code></pre>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<pre><code>git-svn dcommit</code></pre>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<pre><code>git-svn rebase</code></pre>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
git checkout -f
hellekin
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T23:53:55-07:00
Git Cheat Sheet - version 26
Mon Aug 04 23:53:55 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from <span class="caps">GIT</span> screencast at https://www.peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<p>git config—global user.name “David Beckwith”</p>
<p>git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:</p>
<p>git config—list</p>
<p>OR</p>
<p>cat .gitconfig</p>
<h4><span class="caps">SET UP ALIASES</span></h4>
<p>git config—global alias.co checkout</p>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<p>cat .gitconfig</p>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<p>git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:</p>
<p>gb = git branch</p>
<p>gba = git branch -a</p>
<p>gc = git commit -v</p>
<p>gd = git diff | mate</p>
<p>gl = git pull</p>
<p>gp = git push</p>
<p>gst = git status</p>
<h3><span class="caps">START USING GIT</span>:</h3>
<p>git init</p>
<h4><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</h4>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</h4>
<p>git add .</p>
<h4><span class="caps">TO SEE WHAT THE STATUS</span>:</h4>
<p>git status</p>
<h4><span class="caps">TO COMMIT</span>:</h4>
<p>git commit -m “First import”</p>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</h4>
<p>git ls-files</p>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</h4>
<p>git rm <file name></p>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</h4>
<p>git commit -a</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</h4>
<p>git add <file name></p>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git commit -v</p>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<p>git commit -m “This is the message describing the commit”</p>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<p>git commit -a</p>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<p>git commit -a -v</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<p>git log</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span></h4>
<p>git log—stat</p>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git log -v</p>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<p>gitk—all</p>
<h4><span class="caps">TO CREATE A NEW BRANCH</span>:</h4>
<p>git branch <name of your new branch></p>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<p>git branch</p>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<p>git branch -a</p>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</h4>
<p>git checkout <name of the branch you want to switch to></p>
<p>OR</p>
<p>git co <name of the branch you want to switch to></p>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:</h4>
<p>git rebase master</p>
h4. <span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
<p>git co master</p>
<code> check to see what changes you're about to merge together, compare the two branches:</code>
<p>git diff master xyz</p>
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
<p>git merge xyz</p>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<p>git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<p>git checkout -b <name of new branch></p>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<p>git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<p>git co <branch you want to switch to></p>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
<p>git co <the stashed branch></p>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<p>git stash list</p>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”</h4>
<p>git stash apply</p>
<code> now you can continue to work where you were previously.</code>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<p>git branch -d <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span></h4>
<p>git branch -D <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<p>git stash clear</p>
h4. <span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
<p>scp -r my_project deploy@yourbox.com:my_project</p>
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
<p>sudo chown -R git:git my_project</p>
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<p>git clone git@yourbox.com:/var/git/my_project</p>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<p>cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<p>git pull</p>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<p>git fetch laptop</p>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<p>git merge laptop/xyz</p>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<p>git remote show laptop</p>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<p>git push laptop xyz</p>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<p>git branch—track <local name of branch> <remote name of branch></p>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<p>git pull</p>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<p>git remote show origin</p>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<p>git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<p>git-svn dcommit</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<p>git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
<p>git checkout -f</p>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T23:42:45-07:00
Git Cheat Sheet - version 25
Mon Aug 04 23:42:45 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<p>(credit: notes extracted from extracted from <span class="caps">GIT</span> screencast at https://peepcode.com.)</p>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<p>git config—global user.name “David Beckwith”</p>
<p>git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:</p>
<p>git config—list</p>
<p>OR</p>
<p>cat .gitconfig</p>
<h4><span class="caps">SET UP ALIASES</span></h4>
<p>git config—global alias.co checkout</p>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<p>cat .gitconfig</p>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<p>git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:</p>
<p>gb = git branch</p>
<p>gba = git branch -a</p>
<p>gc = git commit -v</p>
<p>gd = git diff | mate</p>
<p>gl = git pull</p>
<p>gp = git push</p>
<p>gst = git status</p>
<h3><span class="caps">START USING GIT</span>:</h3>
<p>git init</p>
<h4><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</h4>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</h4>
<p>git add .</p>
<h4><span class="caps">TO SEE WHAT THE STATUS</span>:</h4>
<p>git status</p>
<h4><span class="caps">TO COMMIT</span>:</h4>
<p>git commit -m “First import”</p>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</h4>
<p>git ls-files</p>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</h4>
<p>git rm <file name></p>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</h4>
<p>git commit -a</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</h4>
<p>git add <file name></p>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git commit -v</p>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<p>git commit -m “This is the message describing the commit”</p>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<p>git commit -a</p>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<p>git commit -a -v</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<p>git log</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span></h4>
<p>git log—stat</p>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git log -v</p>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<p>gitk—all</p>
<h4><span class="caps">TO CREATE A NEW BRANCH</span>:</h4>
<p>git branch <name of your new branch></p>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<p>git branch</p>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<p>git branch -a</p>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</h4>
<p>git checkout <name of the branch you want to switch to></p>
<p>OR</p>
<p>git co <name of the branch you want to switch to></p>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:</h4>
<p>git rebase master</p>
h4. <span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
<p>git co master</p>
<code> check to see what changes you're about to merge together, compare the two branches:</code>
<p>git diff master xyz</p>
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
<p>git merge xyz</p>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<p>git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<p>git checkout -b <name of new branch></p>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<p>git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<p>git co <branch you want to switch to></p>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
<p>git co <the stashed branch></p>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<p>git stash list</p>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”</h4>
<p>git stash apply</p>
<code> now you can continue to work where you were previously.</code>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<p>git branch -d <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span></h4>
<p>git branch -D <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<p>git stash clear</p>
h4. <span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
<p>scp -r my_project deploy@yourbox.com:my_project</p>
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
<p>sudo chown -R git:git my_project</p>
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<p>git clone git@yourbox.com:/var/git/my_project</p>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<p>cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<p>git pull</p>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<p>git fetch laptop</p>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<p>git merge laptop/xyz</p>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<p>git remote show laptop</p>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<p>git push laptop xyz</p>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<p>git branch—track <local name of branch> <remote name of branch></p>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<p>git pull</p>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<p>git remote show origin</p>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<p>git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<p>git-svn dcommit</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<p>git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
<p>git checkout -f</p>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T23:42:09-07:00
Git Cheat Sheet - version 24
Mon Aug 04 23:42:09 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<h3><span class="caps">CONFIGURE</span>
(credit: notes extracted from extracted from <span class="caps">GIT</span> screencast at https://peepcode.com.)</h3>
<p>identify yourself to git: email and your name</p>
<p>git config—global user.name “David Beckwith”</p>
<p>git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:</p>
<p>git config—list</p>
<p>OR</p>
<p>cat .gitconfig</p>
<h4><span class="caps">SET UP ALIASES</span></h4>
<p>git config—global alias.co checkout</p>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<p>cat .gitconfig</p>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<p>git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:</p>
<p>gb = git branch</p>
<p>gba = git branch -a</p>
<p>gc = git commit -v</p>
<p>gd = git diff | mate</p>
<p>gl = git pull</p>
<p>gp = git push</p>
<p>gst = git status</p>
<h3><span class="caps">START USING GIT</span>:</h3>
<p>git init</p>
<h4><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</h4>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</h4>
<p>git add .</p>
<h4><span class="caps">TO SEE WHAT THE STATUS</span>:</h4>
<p>git status</p>
<h4><span class="caps">TO COMMIT</span>:</h4>
<p>git commit -m “First import”</p>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</h4>
<p>git ls-files</p>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</h4>
<p>git rm <file name></p>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</h4>
<p>git commit -a</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</h4>
<p>git add <file name></p>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git commit -v</p>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<p>git commit -m “This is the message describing the commit”</p>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<p>git commit -a</p>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<p>git commit -a -v</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<p>git log</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span></h4>
<p>git log—stat</p>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git log -v</p>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<p>gitk—all</p>
<h4><span class="caps">TO CREATE A NEW BRANCH</span>:</h4>
<p>git branch <name of your new branch></p>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<p>git branch</p>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<p>git branch -a</p>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</h4>
<p>git checkout <name of the branch you want to switch to></p>
<p>OR</p>
<p>git co <name of the branch you want to switch to></p>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:</h4>
<p>git rebase master</p>
h4. <span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
<p>git co master</p>
<code> check to see what changes you're about to merge together, compare the two branches:</code>
<p>git diff master xyz</p>
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
<p>git merge xyz</p>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<p>git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<p>git checkout -b <name of new branch></p>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<p>git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<p>git co <branch you want to switch to></p>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
<p>git co <the stashed branch></p>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<p>git stash list</p>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”</h4>
<p>git stash apply</p>
<code> now you can continue to work where you were previously.</code>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<p>git branch -d <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span></h4>
<p>git branch -D <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<p>git stash clear</p>
h4. <span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
<p>scp -r my_project deploy@yourbox.com:my_project</p>
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
<p>sudo chown -R git:git my_project</p>
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<p>git clone git@yourbox.com:/var/git/my_project</p>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<p>cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<p>git pull</p>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<p>git fetch laptop</p>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<p>git merge laptop/xyz</p>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<p>git remote show laptop</p>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<p>git push laptop xyz</p>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<p>git branch—track <local name of branch> <remote name of branch></p>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<p>git pull</p>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<p>git remote show origin</p>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<p>git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<p>git-svn dcommit</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<p>git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
<p>git checkout -f</p>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T23:12:22-07:00
Git Cheat Sheet - version 23
Mon Aug 04 23:12:22 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<p>git config—global user.name “David Beckwith”</p>
<p>git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:</p>
<p>git config—list</p>
<p>OR</p>
<p>cat .gitconfig</p>
<h4><span class="caps">SET UP ALIASES</span></h4>
<p>git config—global alias.co checkout</p>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<p>cat .gitconfig</p>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<p>git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:</p>
<p>gb = git branch</p>
<p>gba = git branch -a</p>
<p>gc = git commit -v</p>
<p>gd = git diff | mate</p>
<p>gl = git pull</p>
<p>gp = git push</p>
<p>gst = git status</p>
<h3><span class="caps">START USING GIT</span>:</h3>
<p>git init</p>
<h4><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</h4>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</h4>
<p>git add .</p>
<h4><span class="caps">TO SEE WHAT THE STATUS</span>:</h4>
<p>git status</p>
<h4><span class="caps">TO COMMIT</span>:</h4>
<p>git commit -m “First import”</p>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</h4>
<p>git ls-files</p>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</h4>
<p>git rm <file name></p>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</h4>
<p>git commit -a</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</h4>
<p>git add <file name></p>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git commit -v</p>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<p>git commit -m “This is the message describing the commit”</p>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<p>git commit -a</p>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<p>git commit -a -v</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<p>git log</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span></h4>
<p>git log—stat</p>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git log -v</p>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<p>gitk—all</p>
<h4><span class="caps">TO CREATE A NEW BRANCH</span>:</h4>
<p>git branch <name of your new branch></p>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<p>git branch</p>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<p>git branch -a</p>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</h4>
<p>git checkout <name of the branch you want to switch to></p>
<p>OR</p>
<p>git co <name of the branch you want to switch to></p>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:</h4>
<p>git rebase master</p>
h4. <span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
<p>git co master</p>
<code> check to see what changes you're about to merge together, compare the two branches:</code>
<p>git diff master xyz</p>
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
<p>git merge xyz</p>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<p>git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<p>git checkout -b <name of new branch></p>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<p>git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<p>git co <branch you want to switch to></p>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
<p>git co <the stashed branch></p>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<p>git stash list</p>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”</h4>
<p>git stash apply</p>
<code> now you can continue to work where you were previously.</code>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<p>git branch -d <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span></h4>
<p>git branch -D <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<p>git stash clear</p>
h4. <span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
<p>scp -r my_project deploy@yourbox.com:my_project</p>
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
<p>sudo chown -R git:git my_project</p>
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<p>git clone git@yourbox.com:/var/git/my_project</p>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<p>cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<p>git pull</p>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<p>git fetch laptop</p>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<p>git merge laptop/xyz</p>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<p>git remote show laptop</p>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<p>git push laptop xyz</p>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<p>git branch—track <local name of branch> <remote name of branch></p>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<p>git pull</p>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<p>git remote show origin</p>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<p>git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<p>git-svn dcommit</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<p>git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
<p>git checkout -f</p>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T23:09:45-07:00
Git Cheat Sheet - version 22
Mon Aug 04 23:09:45 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<p>git config—global user.name “David Beckwith”</p>
<p>git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:</p>
<p>git config—list</p>
<p>OR</p>
<p>cat .gitconfig</p>
<h4><span class="caps">SET UP ALIASES</span></h4>
<p>git config—global alias.co checkout</p>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<p>cat .gitconfig</p>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<p>git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:</p>
<p>gb = git branch</p>
<p>gba = git branch -a</p>
<p>gc = git commit -v</p>
<p>gd = git diff | mate</p>
<p>gl = git pull</p>
<p>gp = git push</p>
<p>gst = git status</p>
<h3><span class="caps">START USING GIT</span>:</h3>
<p>git init</p>
<h4><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</h4>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</h4>
<p>git add .</p>
<h4><span class="caps">TO SEE WHAT THE STATUS</span>:</h4>
<p>git status</p>
<h4><span class="caps">TO COMMIT</span>:</h4>
<p>git commit -m “First import”</p>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</h4>
<p>git ls-files</p>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</h4>
<p>git rm <file name></p>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</h4>
<p>git commit -a</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</h4>
<p>git add <file name></p>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git commit -v</p>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<p>git commit -m “This is the message describing the commit”</p>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<p>git commit -a</p>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<p>git commit -a -v</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<p>git log</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span></h4>
<p>git log—stat</p>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git log -v</p>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<p>gitk—all</p>
<h4><span class="caps">TO CREATE A NEW BRANCH</span>:</h4>
<p>git branch <name of your new branch></p>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<p>git branch</p>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<p>git branch -a</p>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</h4>
<p>git checkout <name of the branch you want to switch to></p>
<p>OR</p>
<p>git co <name of the branch you want to switch to></p>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>::</h4>
<p>git rebase master</p>
h4. <span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
<p>git co master</p>
<code> check to see what changes you're about to merge together, compare the two branches:</code>
<p>git diff master xyz</p>
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
<p>git merge xyz</p>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<p>git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<p>git checkout -b <name of new branch></p>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<p>git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<p>git co <branch you want to switch to></p>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
<p>git co <the stashed branch></p>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<p>git stash list</p>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”</h4>
<p>git stash apply</p>
<code> now you can continue to work where you were previously.</code>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<p>git branch -d <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span></h4>
<p>git branch -D <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<p>git stash clear</p>
h4. <span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
<p>scp -r my_project deploy@yourbox.com:my_project</p>
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
<p>sudo chown -R git:git my_project</p>
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<p>git clone git@yourbox.com:/var/git/my_project</p>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<p>cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:</h4>
<p>git pull</p>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span></h4>
<p>git fetch laptop</p>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<p>git merge laptop/xyz</p>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<p>git remote show laptop</p>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<p>git push laptop xyz</p>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<p>git branch—track <local name of branch> <remote name of branch></p>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:</h4>
<p>git pull</p>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<p>git remote show origin</p>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<p>git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<p>git-svn dcommit</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<p>git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
<p>git checkout -f</p>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T23:05:38-07:00
Git Cheat Sheet - version 21
Mon Aug 04 23:05:38 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<p>git config—global user.name “David Beckwith”</p>
<p>git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:</p>
<p>git config—list</p>
<p>OR</p>
<p>cat .gitconfig</p>
<h4><span class="caps">SET UP ALIASES</span></h4>
<p>git config—global alias.co checkout</p>
<h4><span class="caps">VIEW YOUR CONFIGURATION</span></h4>
<p>cat .gitconfig</p>
<h4><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h4>
<p>git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:</p>
<p>gb = git branch</p>
<p>gba = git branch -a</p>
<p>gc = git commit -v</p>
<p>gd = git diff | mate</p>
<p>gl = git pull</p>
<p>gp = git push</p>
<p>gst = git status</p>
<h3><span class="caps">START USING GIT</span>:</h3>
<p>git init</p>
<h4><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</h4>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</h4>
<p>git add .</p>
<h4><span class="caps">TO SEE WHAT THE STATUS</span>:</h4>
<p>git status</p>
<h4><span class="caps">TO COMMIT</span>:</h4>
<p>git commit -m “First import”</p>
<h4><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</h4>
<p>git ls-files</p>
<h4><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</h4>
<p>git rm <file name></p>
<h4><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</h4>
<p>git commit -a</p>
<h4><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</h4>
<p>git add <file name></p>
<h4><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git commit -v</p>
<h4><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></h4>
<p>git commit -m “This is the message describing the commit”</p>
<h4><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></h4>
<p>git commit -a</p>
<h4><span class="caps">THE NORMAL COMMIT COMMAND</span>:</h4>
<p>git commit -a -v</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></h4>
<p>git log</p>
<h4><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span></h4>
<p>git log—stat</p>
<h4><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></h4>
<p>git log -v</p>
<h4><span class="caps">TO VISUALIZE YOUR CHANGES</span></h4>
<p>gitk—all</p>
<h4><span class="caps">TO CREATE A NEW BRANCH</span>:</h4>
<p>git branch <name of your new branch></p>
<h4><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></h4>
<p>git branch</p>
<h4><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></h4>
<p>git branch -a</p>
<h4><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</h4>
<p>git checkout <name of the branch you want to switch to></p>
<p>OR</p>
<p>git co <name of the branch you want to switch to></p>
<h4><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:</h4>
<p>git rebase master</p>
h4. <span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
<p>git co master</p>
<code> check to see what changes you're about to merge together, compare the two branches:</code>
<p>git diff master xyz</p>
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
<p>git merge xyz</p>
<h4><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</h4>
<p>git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<h4><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file.</h4>
<p>Remove the markings, add the file, then commit.</p>
<h4><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</h4>
<p>git checkout -b <name of new branch></p>
<h4><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</h4>
<p>git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<h4><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></h4>
<p>git co <branch you want to switch to></p>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
<p>git co <the stashed branch></p>
<h4><span class="caps">TO VIEW THE LIST OF STASHES</span></h4>
<p>git stash list</p>
<h4><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”</h4>
<p>git stash apply</p>
<code> now you can continue to work where you were previously.</code>
<h4><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</h4>
<p>git branch -d <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE AN UNMERGED BRANCH</span></h4>
<p>git branch -D <name of branch you want to delete></p>
<h4><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</h4>
<p>git stash clear</p>
h4. <span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
<p>scp -r my_project deploy@yourbox.com:my_project</p>
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
<p>sudo chown -R git:git my_project</p>
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<h4><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</h4>
<p>git clone git@yourbox.com:/var/git/my_project</p>
<h4><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</h4>
<p>cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<h4><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:
git pull</h4>
<h4><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span>
git fetch laptop</h4>
<h4><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></h4>
<p>git merge laptop/xyz</p>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<h4><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></h4>
<h4><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></h4>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<h4><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></h4>
<p>git remote show laptop</p>
<h4><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></h4>
<p>git push laptop xyz</p>
<h4><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</h4>
<p>git branch—track <local name of branch> <remote name of branch></p>
<h4><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:
git pull</h4>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<h4><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</h4>
<p>git remote show origin</p>
<h4><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</h4>
<p>git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<h4><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></h4>
<p>git-svn dcommit</p>
<h4><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></h4>
<p>git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
<p>git checkout -f</p>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T23:00:04-07:00
Git Cheat Sheet - version 20
Mon Aug 04 23:00:04 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<p>git config—global user.name “David Beckwith”</p>
<p>git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:</p>
<p>git config—list</p>
<p>OR</p>
<p>cat .gitconfig</p>
<h4><span class="caps">SET UP ALIASES</span></h4>
<p>git config—global alias.co checkout</p>
<p><span class="caps">VIEW YOUR CONFIGURATION</span></p>
<p>cat .gitconfig</p>
<p><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</p>
<p>git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:</p>
<p>gb = git branch</p>
<p>gba = git branch -a</p>
<p>gc = git commit -v</p>
<p>gd = git diff | mate</p>
<p>gl = git pull</p>
<p>gp = git push</p>
<p>gst = git status</p>
<h3><span class="caps">START USING GIT</span>:</h3>
<p>git init</p>
<p><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</p>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</p>
<p>git add .</p>
<p><span class="caps">TO SEE WHAT THE STATUS</span>:</p>
<p>git status</p>
<p><span class="caps">TO COMMIT</span>:</p>
<p>git commit -m “First import”</p>
<p><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</p>
<p>git ls-files</p>
<p><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</p>
<p>git rm <file name></p>
<p><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</p>
<p>git commit -a</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</p>
<p>git add <file name></p>
<p><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></p>
<p>git commit -v</p>
<p><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></p>
<p>git commit -m “This is the message describing the commit”</p>
<p><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></p>
<p>git commit -a</p>
<p><span class="caps">THE NORMAL COMMIT COMMAND</span>:</p>
<p>git commit -a -v</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></p>
<p>git log</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span></p>
<p>git log—stat</p>
<p><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></p>
<p>git log -v</p>
<p><span class="caps">TO VISUALIZE YOUR CHANGES</span></p>
<p>gitk—all</p>
<p><span class="caps">TO CREATE A NEW BRANCH</span>:</p>
<p>git branch <name of your new branch></p>
<p><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></p>
<p>git branch</p>
<p><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></p>
<p>git branch -a</p>
<p><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</p>
<p>git checkout <name of the branch you want to switch to></p>
<p>OR</p>
<p>git co <name of the branch you want to switch to></p>
<p><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:</p>
<p>git rebase master</p>
<span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
<p>git co master</p>
<code> check to see what changes you're about to merge together, compare the two branches:</code>
<p>git diff master xyz</p>
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
<p>git merge xyz</p>
<p><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</p>
<p>git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<p><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file. Remove the markings, add the file, then commit.</p>
<p><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</p>
<p>git checkout -b <name of new branch></p>
<p><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</p>
<p>git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<p><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></p>
<p>git co <branch you want to switch to></p>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
<p>git co <the stashed branch></p>
<p><span class="caps">TO VIEW THE LIST OF STASHES</span></p>
<p>git stash list</p>
<p><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”</p>
<p>git stash apply</p>
<code> now you can continue to work where you were previously.</code>
<p><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</p>
<p>git branch -d <name of branch you want to delete></p>
<p><span class="caps">TO DELETE AN UNMERGED BRANCH</span></p>
<p>git branch -D <name of branch you want to delete></p>
<p><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</p>
<p>git stash clear</p>
<span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
<p>scp -r my_project deploy@yourbox.com:my_project</p>
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
<p>sudo chown -R git:git my_project</p>
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<p><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</p>
<p>git clone git@yourbox.com:/var/git/my_project</p>
<p><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</p>
<p>cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<p><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:
git pull</p>
<p><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span>
git fetch laptop</p>
<p><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></p>
<p>git merge laptop/xyz</p>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<p><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></p>
<p><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></p>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<p><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></p>
<p>git remote show laptop</p>
<p><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></p>
<p>git push laptop xyz</p>
<p><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</p>
<p>git branch—track <local name of branch> <remote name of branch></p>
<p><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:
git pull</p>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<p><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</p>
<p>git remote show origin</p>
<p><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</p>
<p>git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<p><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></p>
<p>git-svn dcommit</p>
<p><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></p>
<p>git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
<p>git checkout -f</p>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T22:58:30-07:00
Git Cheat Sheet - version 19
Mon Aug 04 22:58:30 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<p>git config—global user.name “David Beckwith”</p>
<p>git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:</p>
<p>git config—list</p>
<p>OR</p>
<p>cat .gitconfig</p>
<p><span class="caps">SET UP ALIASES</span></p>
<p>git config—global alias.co checkout</p>
<p><span class="caps">VIEW YOUR CONFIGURATION</span></p>
<p>cat .gitconfig</p>
<p><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</p>
<p>git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:</p>
<p>gb = git branch</p>
<p>gba = git branch -a</p>
<p>gc = git commit -v</p>
<p>gd = git diff | mate</p>
<p>gl = git pull</p>
<p>gp = git push</p>
<p>gst = git status</p>
<h3><span class="caps">START USING GIT</span>:</h3>
<p>git init</p>
<p><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</p>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</p>
<p>git add .</p>
<p><span class="caps">TO SEE WHAT THE STATUS</span>:</p>
<p>git status</p>
<p><span class="caps">TO COMMIT</span>:</p>
<p>git commit -m “First import”</p>
<p><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</p>
<p>git ls-files</p>
<p><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</p>
<p>git rm <file name></p>
<p><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</p>
<p>git commit -a</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</p>
<p>git add <file name></p>
<p><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></p>
<p>git commit -v</p>
<p><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></p>
<p>git commit -m “This is the message describing the commit”</p>
<p><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></p>
<p>git commit -a</p>
<p><span class="caps">THE NORMAL COMMIT COMMAND</span>:</p>
<p>git commit -a -v</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></p>
<p>git log</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span></p>
<p>git log—stat</p>
<p><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></p>
<p>git log -v</p>
<p><span class="caps">TO VISUALIZE YOUR CHANGES</span></p>
<p>gitk—all</p>
<p><span class="caps">TO CREATE A NEW BRANCH</span>:</p>
<p>git branch <name of your new branch></p>
<p><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></p>
<p>git branch</p>
<p><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></p>
<p>git branch -a</p>
<p><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</p>
<p>git checkout <name of the branch you want to switch to></p>
<p>OR</p>
<p>git co <name of the branch you want to switch to></p>
<p><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:</p>
<p>git rebase master</p>
<span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
<p>git co master</p>
<code> check to see what changes you're about to merge together, compare the two branches:</code>
<p>git diff master xyz</p>
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
<p>git merge xyz</p>
<p><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</p>
<p>git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<p><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file. Remove the markings, add the file, then commit.</p>
<p><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</p>
<p>git checkout -b <name of new branch></p>
<p><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</p>
<p>git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<p><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></p>
<p>git co <branch you want to switch to></p>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
<p>git co <the stashed branch></p>
<p><span class="caps">TO VIEW THE LIST OF STASHES</span></p>
<p>git stash list</p>
<p><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”</p>
<p>git stash apply</p>
<code> now you can continue to work where you were previously.</code>
<p><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</p>
<p>git branch -d <name of branch you want to delete></p>
<p><span class="caps">TO DELETE AN UNMERGED BRANCH</span></p>
<p>git branch -D <name of branch you want to delete></p>
<p><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</p>
<p>git stash clear</p>
<span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
<p>scp -r my_project deploy@yourbox.com:my_project</p>
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
<p>sudo chown -R git:git my_project</p>
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<p><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</p>
<p>git clone git@yourbox.com:/var/git/my_project</p>
<p><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</p>
<p>cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<p><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:
git pull</p>
<p><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span>
git fetch laptop</p>
<p><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></p>
<p>git merge laptop/xyz</p>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<p><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></p>
<p><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></p>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<p><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></p>
<p>git remote show laptop</p>
<p><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></p>
<p>git push laptop xyz</p>
<p><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</p>
<p>git branch—track <local name of branch> <remote name of branch></p>
<p><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:
git pull</p>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<p><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</p>
<p>git remote show origin</p>
<p><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</p>
<p>git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<p><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></p>
<p>git-svn dcommit</p>
<p><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></p>
<p>git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
<p>git checkout -f</p>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T22:57:06-07:00
Git Cheat Sheet - version 18
Mon Aug 04 22:57:06 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<h2>A Practical Git <span class="caps">GUIDE</span></h2>
<h3><span class="caps">CONFIGURE</span></h3>
<p>identify yourself to git: email and your name</p>
<p>git config—global user.name “David Beckwith”</p>
<p>git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:</p>
<p>git config—list</p>
<p>OR</p>
<p>cat .gitconfig</p>
<p><span class="caps">SET UP ALIASES</span></p>
<p>git config—global alias.co checkout</p>
<h3><span class="caps">VIEW YOUR CONFIGURATION</span></h3>
<p>cat .gitconfig</p>
<h3><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</h3>
<p>git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:</p>
<p>gb = git branch</p>
<p>gba = git branch -a</p>
<p>gc = git commit -v</p>
<p>gd = git diff | mate</p>
<p>gl = git pull</p>
<p>gp = git push</p>
<p>gst = git status</p>
<h3><span class="caps">START USING GIT</span>:</h3>
<p>git init</p>
<p><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</p>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</p>
<p>git add .</p>
<p><span class="caps">TO SEE WHAT THE STATUS</span>:</p>
<p>git status</p>
<p><span class="caps">TO COMMIT</span>:</p>
<p>git commit -m “First import”</p>
<p><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</p>
<p>git ls-files</p>
<p><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</p>
<p>git rm <file name></p>
<p><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</p>
<p>git commit -a</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</p>
<p>git add <file name></p>
<p><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></p>
<p>git commit -v</p>
<p><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></p>
<p>git commit -m “This is the message describing the commit”</p>
<p><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></p>
<p>git commit -a</p>
<p><span class="caps">THE NORMAL COMMIT COMMAND</span>:</p>
<p>git commit -a -v</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></p>
<p>git log</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span></p>
<p>git log—stat</p>
<p><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></p>
<p>git log -v</p>
<p><span class="caps">TO VISUALIZE YOUR CHANGES</span></p>
<p>gitk—all</p>
<p><span class="caps">TO CREATE A NEW BRANCH</span>:</p>
<p>git branch <name of your new branch></p>
<p><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></p>
<p>git branch</p>
<p><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></p>
<p>git branch -a</p>
<p><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</p>
<p>git checkout <name of the branch you want to switch to></p>
<p>OR</p>
<p>git co <name of the branch you want to switch to></p>
<p><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:</p>
<p>git rebase master</p>
<span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
<p>git co master</p>
<code> check to see what changes you're about to merge together, compare the two branches:</code>
<p>git diff master xyz</p>
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
<p>git merge xyz</p>
<p><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</p>
<p>git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<p><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file. Remove the markings, add the file, then commit.</p>
<p><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</p>
<p>git checkout -b <name of new branch></p>
<p><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</p>
<p>git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<p><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></p>
<p>git co <branch you want to switch to></p>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
<p>git co <the stashed branch></p>
<p><span class="caps">TO VIEW THE LIST OF STASHES</span></p>
<p>git stash list</p>
<p><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”</p>
<p>git stash apply</p>
<code> now you can continue to work where you were previously.</code>
<p><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</p>
<p>git branch -d <name of branch you want to delete></p>
<p><span class="caps">TO DELETE AN UNMERGED BRANCH</span></p>
<p>git branch -D <name of branch you want to delete></p>
<p><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</p>
<p>git stash clear</p>
<span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
<p>scp -r my_project deploy@yourbox.com:my_project</p>
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
<p>sudo chown -R git:git my_project</p>
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<p><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</p>
<p>git clone git@yourbox.com:/var/git/my_project</p>
<p><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</p>
<p>cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<p><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:
git pull</p>
<p><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span>
git fetch laptop</p>
<p><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></p>
<p>git merge laptop/xyz</p>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<p><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></p>
<p><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></p>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<p><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></p>
<p>git remote show laptop</p>
<p><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></p>
<p>git push laptop xyz</p>
<p><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</p>
<p>git branch—track <local name of branch> <remote name of branch></p>
<p><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:
git pull</p>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<p><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</p>
<p>git remote show origin</p>
<p><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</p>
<p>git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<p><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></p>
<p>git-svn dcommit</p>
<p><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></p>
<p>git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
<p>git checkout -f</p>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T22:52:59-07:00
Git Cheat Sheet - version 17
Mon Aug 04 22:52:59 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<p>A practical Git Guide:
<span class="caps">CONFIGURE</span>
identify yourself to git: email and your name</p>
<p>git config—global user.name “David Beckwith”</p>
<p>git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:</p>
<p>git config—list</p>
<p>OR</p>
<p>cat .gitconfig</p>
<p><span class="caps">SET UP ALIASES</span></p>
<p>git config—global alias.co checkout</p>
<p><span class="caps">VIEW YOUR CONFIGURATION</span></p>
<p>cat .gitconfig</p>
<p><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)</p>
<p>git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:</p>
<p>gb = git branch</p>
<p>gba = git branch -a</p>
<p>gc = git commit -v</p>
<p>gd = git diff | mate</p>
<p>gl = git pull</p>
<p>gp = git push</p>
<p>gst = git status</p>
<p><span class="caps">START USING GIT</span>:</p>
<p>git init</p>
<p><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.</p>
<p>*.log</p>
<p>db/schema.rb</p>
<p>db/schema.sql</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:</p>
<p>git add .</p>
<p><span class="caps">TO SEE WHAT THE STATUS</span>:</p>
<p>git status</p>
<p><span class="caps">TO COMMIT</span>:</p>
<p>git commit -m “First import”</p>
<p><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:</p>
<p>git ls-files</p>
<p><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:</p>
<p>git rm <file name></p>
<p><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:</p>
<p>git commit -a</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:</p>
<p>git add <file name></p>
<p><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span></p>
<p>git commit -v</p>
<p><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span></p>
<p>git commit -m “This is the message describing the commit”</p>
<p><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span></p>
<p>git commit -a</p>
<p><span class="caps">THE NORMAL COMMIT COMMAND</span>:</p>
<p>git commit -a -v</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span></p>
<p>git log</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span></p>
<p>git log—stat</p>
<p><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span></p>
<p>git log -v</p>
<p><span class="caps">TO VISUALIZE YOUR CHANGES</span></p>
<p>gitk—all</p>
<p><span class="caps">TO CREATE A NEW BRANCH</span>:</p>
<p>git branch <name of your new branch></p>
<p><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span></p>
<p>git branch</p>
<p><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span></p>
<p>git branch -a</p>
<p><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.</p>
<p>git checkout <name of the branch you want to switch to></p>
<p>OR</p>
<p>git co <name of the branch you want to switch to></p>
<p><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:</p>
<p>git rebase master</p>
<span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
<p>git co master</p>
<code> check to see what changes you're about to merge together, compare the two branches:</code>
<p>git diff master xyz</p>
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
<p>git merge xyz</p>
<p><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.</p>
<p>git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<p><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file. Remove the markings, add the file, then commit.</p>
<p><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:</p>
<p>git checkout -b <name of new branch></p>
<p><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.</p>
<p>git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<p><span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span></p>
<p>git co <branch you want to switch to></p>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
<p>git co <the stashed branch></p>
<p><span class="caps">TO VIEW THE LIST OF STASHES</span></p>
<p>git stash list</p>
<p><span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”</p>
<p>git stash apply</p>
<code> now you can continue to work where you were previously.</code>
<p><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)</p>
<p>git branch -d <name of branch you want to delete></p>
<p><span class="caps">TO DELETE AN UNMERGED BRANCH</span></p>
<p>git branch -D <name of branch you want to delete></p>
<p><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)</p>
<p>git stash clear</p>
<span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
<p>scp -r my_project deploy@yourbox.com:my_project</p>
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
<p>sudo chown -R git:git my_project</p>
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<p><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:</p>
<p>git clone git@yourbox.com:/var/git/my_project</p>
<p><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:</p>
<p>cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<p><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:
git pull</p>
<p><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span>
git fetch laptop</p>
<p><span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span></p>
<p>git merge laptop/xyz</p>
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<p><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></p>
<p><span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span></p>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<p><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span></p>
<p>git remote show laptop</p>
<p><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span></p>
<p>git push laptop xyz</p>
<p><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:</p>
<p>git branch—track <local name of branch> <remote name of branch></p>
<p><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:
git pull</p>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<p><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:</p>
<p>git remote show origin</p>
<p><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:</p>
<p>git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<p><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span></p>
<p>git-svn dcommit</p>
<p><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span></p>
<p>git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
<p>git checkout -f</p>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T22:49:31-07:00
Git Cheat Sheet - version 16
Mon Aug 04 22:49:31 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<p>A practical Git Guide:</p>
<p><span class="caps">CONFIGURE</span>
identify yourself to git: email and your name
git config—global user.name “David Beckwith”
git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:
git config—list
OR
cat .gitconfig</p>
<p><span class="caps">SET UP ALIASES</span>
git config—global alias.co checkout</p>
<p><span class="caps">VIEW YOUR CONFIGURATION</span>
cat .gitconfig</p>
<p><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)
git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:
gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</p>
<p><span class="caps">START USING GIT</span>:
git init</p>
<p><span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
comments begin with hash.
*.log
db/schema.rb
db/schema.sql</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:
git add .</p>
<p><span class="caps">TO SEE WHAT THE STATUS</span>:
git status</p>
<p><span class="caps">TO COMMIT</span>:
git commit -m “First import”</p>
<p><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:
git ls-files</p>
<p><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:
git rm <file name></p>
<p><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:
git commit -a</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:
git add <file name></p>
<p><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span>
git commit -v</p>
<p><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span>
git commit -m “This is the message describing the commit”</p>
<p><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span>
git commit -a</p>
<p><span class="caps">THE NORMAL COMMIT COMMAND</span>:
git commit -a -v</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span>
git log</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span>
git log—stat</p>
<p><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span>
git log -v</p>
<p><span class="caps">TO VISUALIZE YOUR CHANGES</span>
gitk—all</p>
<p><span class="caps">TO CREATE A NEW BRANCH</span>:
git branch <name of your new branch></p>
<p><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span>
git branch</p>
<p><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span>
git branch -a</p>
<p><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.
git checkout <name of the branch you want to switch to>
OR
git co <name of the branch you want to switch to></p>
<p><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:
git rebase master</p>
<span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<code> first switch back to the master branch.</code></code>
git co master
<code> check to see what changes you're about to merge together, compare the two branches:</code>
git diff master xyz
<code>* If you're in a branch that's not the xyz branch and want to merge the xyz branch into it.</code>
git merge xyz
<p><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.
git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<p><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file. Remove the markings, add the file, then commit.</p>
<p><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:
git checkout -b <name of new branch></p>
<p><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.
git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span>
git co <branch you want to switch to>
<code> do whatever</code>
<code> switch back to the stashed branch</code>
git co <the stashed branch>
<p><span class="caps">TO VIEW THE LIST OF STASHES</span>
git stash list</p>
<span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”
git stash apply
<code> now you can continue to work where you were previously.</code>
<p><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)
git branch -d <name of branch you want to delete></p>
<p><span class="caps">TO DELETE AN UNMERGED BRANCH</span>
git branch -D <name of branch you want to delete></p>
<p><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)
git stash clear</p>
<span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<code> Copy up your repository. e.g.:</code>
scp -r my_project deploy@yourbox.com:my_project
<code> Move your files on the remote server to /var/git/my_project</code>
<code> For security make the owner of this project git</code>
<code> On the repository server:</code>
sudo chown -R git:git my_project
<code> then (for security) restrict the "deploy" user to doing git-related things in /etc/passwd with a git-shell.</code>
<p><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:
git clone git@yourbox.com:/var/git/my_project</p>
<p><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:
cat .git/config</p>
<code> By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</code>
<p><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:
git pull</p>
<p><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span>
git fetch laptop</p>
<span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span>
git merge laptop/xyz
<code> this merged the (already copied laptop repository's xyz branch) with the current branch you're sitting in.</code>
<p><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></p>
<span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span>
git remote add laptop duo2book.local:repos/m_project
<code> "laptop" is the name of the remote repository. "duo2book.local" is the name of the machine, I guess</code>
<p><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span>
git remote show laptop</p>
<p><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span>
git push laptop xyz</p>
<p><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:
git branch—track <local name of branch> <remote name of branch></p>
<p><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:
git pull</p>
<code>* Note: You can track(link) different local branches to different remote machines. For example, you can track your friend's "upgrade" branch with your "bobs_upgrade" branch, and simultaneously you can track the origin's "master" branch (of your main webserver) with your local "master" branch.</code>
<code> By convention, 'origin' is the local name given to the remote centralized server which is the way SVN is usually set up on a remote server.</code>
<p><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:
git remote show origin</p>
<p><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:
git-svn clone <http location of an svn repository></p>
<code> Now you can work with the checked out directory as though it was a git repository. (cuz it is)</code>
<p><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span>
git-svn dcommit</p>
<p><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span>
git-svn rebase</p>
<code> NOTE: make sure you have your perl bindings to your local svn installation.</code>
<code> I screwed up, how do I reset my checkout?</code>
git checkout -f
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-08-04T22:06:42-07:00
Git Cheat Sheet - version 15
Mon Aug 04 22:06:42 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
<p>A practical Git Guide:</p>
<p><span class="caps">CONFIGURE</span>
identify yourself to git: email and your name
git config—global user.name “David Beckwith”
git config—global user.email “dbitsolutions@gmail.com”</p>
<p>To view all users:
git config—list
OR
cat .gitconfig</p>
<p><span class="caps">SET UP ALIASES</span>
git config—global alias.co checkout</p>
<p><span class="caps">VIEW YOUR CONFIGURATION</span>
cat .gitconfig</p>
<p><span class="caps">TO IGNORE WHITESPACE</span> (Ruby is whitespace insensitive)
git config—global apply.whitespace nowarn</p>
<p>Some nice aliases:
gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status</p>
<p><span class="caps">START USING GIT</span>:
git init</p>
<span class="caps">TO IGNORE SOME FILES MAKE A FILE</span> (in the root directory) <span class="caps">CALLED</span> .gitignore and add some files to it:
<ol>
<li>comments begin with hash.
*.log
db/schema.rb
db/schema.sql</li>
</ol>
<p><span class="caps">TO SCHEDULE THE ADDITION OF ALL FILES TO THE NEXT COMMIT</span>:
git add .</p>
<p><span class="caps">TO SEE WHAT THE STATUS</span>:
git status</p>
<p><span class="caps">TO COMMIT</span>:
git commit -m “First import”</p>
<p><span class="caps">TO SEE WHAT HAS BEEN COMMITTED</span>:
git ls-files</p>
<p><span class="caps">TO SCHEDULE DELETION OF A FILE</span>:
git rm <file name></p>
<p><span class="caps">TO COMMIT ALL CHANGES IN FILES IN THE CURRENT REPOSITORY</span>:
git commit -a</p>
<p><span class="caps">TO SCHEDULE THE ADDITION OF AN INDIVIDUAL FILE TO THE NEXT COMMIT</span>:
git add <file name></p>
<p><span class="caps">TO VIEW THE DIFFERENCE AS YOU COMMIT USE THE</span> -v <span class="caps">OPTION</span>
git commit -v</p>
<p><span class="caps">TO COMMIT AND TYPE THE MESSAGE ON THE COMMAND LINE USE THE</span> -m <span class="caps">OPTION</span>
git commit -m “This is the message describing the commit”</p>
<p><span class="caps">TO COMMIT AND GET AUTOMATICALLY ANY CHANGES FROM OTHER PEOPLE USE THE</span> -a <span class="caps">OPTION</span>
git commit -a</p>
<p><span class="caps">THE NORMAL COMMIT COMMAND</span>:
git commit -a -v</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS</span>
git log</p>
<p><span class="caps">TO VIEW A LOG OF YOUR COMMITS WITH A GRAPH TO SHOW THE EXTENT OF THE CHANGES</span>
git log—stat</p>
<p><span class="caps">TO HAVE PAGINATION WHEN VIEWING THE LOG FILE USE THE</span> -v <span class="caps">OPTION</span>
git log -v</p>
<p><span class="caps">TO VISUALIZE YOUR CHANGES</span>
gitk—all</p>
<p><span class="caps">TO CREATE A NEW BRANCH</span>:
git branch <name of your new branch></p>
<p><span class="caps">TO VIEW ALL OF THE EXISTING BRANCHES</span>
git branch</p>
<p><span class="caps">TO VIEW A LIST OF ALL BRANCHES</span>
git branch -a</p>
<p><span class="caps">TO SWITCH TO ANOTHER BRANCH</span>. The state of your file system will change after executing this command.
git checkout <name of the branch you want to switch to>
OR
git co <name of the branch you want to switch to></p>
<p><span class="caps">TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH</span> (WHERE <span class="caps">EVERYBODY ELSE IS WORKING</span>) USE <span class="caps">THE REBASE COMMAND</span>:
git rebase master</p>
<span class="caps">TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH</span>.
<ol>
<li>first switch back to the master branch.
git co master</li>
</ol>
<ol>
<li>check to see what changes you’re about to merge together, compare the two branches:
git diff master xyz</li>
</ol>
<ul>
<li>If you’re in a branch that’s not the xyz branch and want to merge the xyz branch into it.
git merge xyz</li>
</ul>
<p><span class="caps">TO REVERT YOUR CHANGES</span> to before the merge.
git reset—hard <span class="caps">ORIG</span>_HEAD</p>
<p><span class="caps">TO RESOLVE CONFLICTS</span> just edit your file. Remove the markings, add the file, then commit.</p>
<p><span class="caps">TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE</span>:
git checkout -b <name of new branch></p>
<p><span class="caps">TO CREATE A</span> “CLIPBOARD” or “STASH” <span class="caps">OF CHANGES THAT ARE NOT YET COMMITED</span> (SO <span class="caps">THAT YOU CAN SWITCH TO ANOTHER BRANCH IN THE MIDDLE OF YOUR CHANGES</span>.), <span class="caps">CREATE A STASH</span>.
git stash “Put a message here to remind you of what you’re saving to the clipboard”</p>
<span class="caps">TO SWITCH AWAY FROM THE CURRENT BRANCH</span>
git co <branch you want to switch to>
<ol>
<li>do whatever</li>
<li>switch back to the stashed branch
git co <the stashed branch></li>
</ol>
<p><span class="caps">TO VIEW THE LIST OF STASHES</span>
git stash list</p>
<span class="caps">TO LOAD BACK THE</span> “CLIPBOARD” OR “STASH”
git stash apply
<ol>
<li>now you can continue to work where you were previously.</li>
</ol>
<p><span class="caps">TO DELETE A BRANCH THAT IS NOT USED ANYMORE</span>, but already merged into the current branch. (TO <span class="caps">CLEAN UP</span>)
git branch -d <name of branch you want to delete></p>
<p><span class="caps">TO DELETE AN UNMERGED BRANCH</span>
git branch -D <name of branch you want to delete></p>
<p><span class="caps">TO DELETE THE STASH</span>. (ERASE <span class="caps">THE</span> “CLIPBOARD” <span class="caps">FROM MEMORY</span>)
git stash clear</p>
<span class="caps">TO SET UP YOUR REPOSITORY FOR SHARING ON A CENTRAL SERVER</span>
<ol>
<li>Copy up your repository. e.g.:
scp -r my_project deploy@yourbox.com:my_project</li>
<li>Move your files on the remote server to /var/git/my_project</li>
<li>For security make the owner of this project git</li>
<li>On the repository server:
sudo chown -R git:git my_project</li>
<li>then (for security) restrict the “deploy” user to doing git-related things in /etc/passwd with a git-shell.</li>
</ol>
<p><span class="caps">TO CHECK OUT THE GIT REPOSITORY TO YOUR LOCALHOST</span>. <span class="caps">ON YOUR LOCAL HOST DO THIS</span>:
git clone git@yourbox.com:/var/git/my_project</p>
<p><span class="caps">TO SEE SOME INFO ABOUT THE REPOSITORY THAT WILL TELL YOU WHICH REPOSITORY IS THE MASTER AND WHICH IS THE SLAVE</span>:
cat .git/config</p>
<ol>
<li>By virtue of having cloned the remote repository, your local repository becomes the slave and will track and synchronize with the remote master branch.</li>
</ol>
<p><span class="caps">TO UPDATE YOUR LOCAL BRANCH FROM THE REMOTE SERVER</span>:
git pull</p>
<p><span class="caps">TO GET A COPY OF THE ENTIRE REMOTE REPOSITORY</span> (e.g. a repository named “laptop”) <span class="caps">WITHOUT MERGING THEM INTO YOUR LOCAL BRANCHES USE FETCH</span>
git fetch laptop</p>
<span class="caps">TO MERGE TWO LOCAL BRANCHES</span> (ie. your local xyz branch with your local master branch) <span class="caps">USE MERGE</span>
git merge laptop/xyz
<ol>
<li>this merged the (already copied laptop repository’s xyz branch) with the current branch you’re sitting in.</li>
</ol>
<p><span class="caps">TO MERGE THE REMOTE BRANCH WITH YOUR LOCAL BRANCH THAT YOU ARE SITTING IN USE PULL</span></p>
<span class="caps">TO ADD LOCAL KNOWLEDGE</span> (TO <span class="caps">YOUR LOCAL REPOSITORY</span>) OF <span class="caps">A 2ND REMOTE REPOSITORY</span>, LIKE <span class="caps">YOUR LAPTOP</span>
git remote add laptop duo2book.local:repos/m_project
<ol>
<li>“laptop” is the name of the remote repository. “duo2book.local” is the name of the machine, I guess</li>
</ol>
<p><span class="caps">TO VIEW META INFORMATION ABOUT THAT REMOTE REPOSITORY</span>
git remote show laptop</p>
<p><span class="caps">TOP PUSH A COMMITTED LOCAL CHANGE OF THE</span> xyz <span class="caps">BRANCH TO THE REMOTE</span> laptop <span class="caps">BRANCH</span>
git push laptop xyz</p>
<p><span class="caps">TO CREATE A TRACKING BRANCH</span> (A <span class="caps">SLAVE BRANCH</span>). Ie. to link a local branch to a remote branch:
git branch—track <local name of branch> <remote name of branch></p>
<p><span class="caps">NOW IF YOU</span>’RE <span class="caps">SITTING IN THE LOCAL TRACKING BRANCH</span>, TO <span class="caps">PULL YOU DON</span>’T <span class="caps">NEED TO SPECIFY THE REMOTE TRACKING BRANCH</span>:
git pull</p>
<ul>
<li>Note: You can track(link) different local branches to different remote machines. For example, you can track your friend’s “upgrade” branch with your “bobs_upgrade” branch, and simultaneously you can track the origin’s “master” branch (of your main webserver) with your local “master” branch.</li>
</ul>
<ol>
<li>By convention, ‘origin’ is the local name given to the remote centralized server which is the way <span class="caps">SVN</span> is usually set up on a remote server.</li>
</ol>
<p><span class="caps">TO SEE WHICH LOCAL BRANCHES ARE TRACKING A REMOTE BRANCH</span>:
git remote show origin</p>
<p><span class="caps">TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY</span>:
git-svn clone <http location of an svn repository></p>
<ol>
<li>Now you can work with the checked out directory as though it was a git repository. (cuz it is)</li>
</ol>
<p><span class="caps">TO PUSH</span> (COMMIT) <span class="caps">CHANGES TO THE REMOTE SERVER</span>
git-svn dcommit</p>
<p><span class="caps">TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY</span>
git-svn rebase</p>
<ol>
<li><span class="caps">NOTE</span>: make sure you have your perl bindings to your local svn installation.</li>
</ol>
<ol>
<li>I screwed up, how do I reset my checkout?
git checkout -f</li>
</ol>
dbit
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-07-11T10:02:19-07:00
Git Cheat Sheet - version 14
Fri Jul 11 10:02:19 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
pjstadig
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T10:39:25-07:00
Git Cheat Sheet - version 13
Fri Apr 18 10:39:25 -0700 2008
<h3>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<span><sub></span>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T10:39:10-07:00
Git Cheat Sheet - version 12
Fri Apr 18 10:39:10 -0700 2008
<h3>Git down in style with Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></h3>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<span><sub></span>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
<h3>cheat.errtheblog.com</h3>
<ul>
<li><a href="https://cheat.errtheblog.com/s/git/">https://cheat.errtheblog.com/s/git/</a></li>
<li><a href="https://cheat.errtheblog.com/s/git_usage/">https://cheat.errtheblog.com/s/git_usage/</a></li>
<li><a href="https://cheat.errtheblog.com/s/gitsvn/">https://cheat.errtheblog.com/s/gitsvn/</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:21:09-07:00
Git Cheat Sheet - version 11
Fri Apr 18 09:21:09 -0700 2008
<p>Git down in style with Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<span><sub></span>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:20:19-07:00
Git Cheat Sheet - version 10
Fri Apr 18 09:20:19 -0700 2008
<p>Git down in style with Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<span><sub></span>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:19:43-07:00
Git Cheat Sheet - version 9
Fri Apr 18 09:19:43 -0700 2008
<p>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<span><sub></span>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<span></sub></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/<span>~</span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:19:27-07:00
Git Cheat Sheet - version 8
Fri Apr 18 09:19:27 -0700 2008
<p>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub><span></span>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/</sub><span></span>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/~<span></span>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:19:09-07:00
Git Cheat Sheet - version 7
Fri Apr 18 09:19:09 -0700 2008
<p>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/~ zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/~ zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/~ zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:19:01-07:00
Git Cheat Sheet - version 6
Fri Apr 18 09:19:01 -0700 2008
<p>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/~ zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/</sub>zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:18:52-07:00
Git Cheat Sheet - version 5
Fri Apr 18 09:18:52 -0700 2008
<p>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/ <sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/</sub>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:18:37-07:00
Git Cheat Sheet - version 4
Fri Apr 18 09:18:37 -0700 2008
<p>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
The <span class="caps">SVG</span> is at:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg">https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</a></li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/</sub>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:18:25-07:00
Git Cheat Sheet - version 3
Fri Apr 18 09:18:25 -0700 2008
<p>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
The <span class="caps">SVG</span> is at:
<ul>
<li>https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</li>
</ul>
Sample png’s are here:
<ul>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png">https://ktown.kde.org/</sub>zrusin/git/git-cheat-sheet-medium.png</a></li>
<li><a href="https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png">https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png</a></li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:18:07-07:00
Git Cheat Sheet - version 2
Fri Apr 18 09:18:07 -0700 2008
<p>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
The <span class="caps">SVG</span> is at:
<ul>
<li>https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</li>
</ul>
Sample png’s are here:
<ul>
<li>https://ktown.kde.org/</sub>zrusin/git/git-cheat-sheet-medium.png</li>
<li>https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png</li>
</ul>
artofmission
tag:github.com,2008:Guide/41
2008-04-18T09:17:49-07:00
2008-04-18T09:17:49-07:00
Git Cheat Sheet - version 1
Fri Apr 18 09:17:49 -0700 2008
<p>Zach Rusin’s <a href="https://zrusin.blogspot.com/2007/09/git-cheat-sheet.html">Git Cheat Sheet</a></p>
<p>The <span class="caps">SVG</span> is at:
https://ktown.kde.org/<sub>zrusin/git/git-cheat-sheet.svg</p>
<p>Sample png’s are here:
https://ktown.kde.org/</sub>zrusin/git/git-cheat-sheet-medium.png
https://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png</p>
artofmission