forked from blynn/gitmagic
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added outline of other chapters and other helper files
- Loading branch information
Ben Lynn
authored and
Ben Lynn
committed
Aug 31, 2007
1 parent
b1b1103
commit f32ad24
Showing
10 changed files
with
290 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
= Branch Magic = | ||
Cheap Context Switching | ||
|
||
== The Boss Key == | ||
|
||
Ever play one of those games where you could hit a special key combination at | ||
any time, and the screen would instantly display a spreadsheet or something? So if the boss walked in the office while you were playing the game you could quickly hide this fact? | ||
|
||
In some directory, edit a text file and write "I'm smarter than my boss". | ||
Create a Git repository, that is, <tt>git-init ; git-add . ; git-commit -m "Initial commit"</tt>. Then type | ||
|
||
$ git checkout -b boss | ||
|
||
Edit the text file to say "My boss is smarter than me", and type <tt>git-commit -a</tt>. Now you can switch between the two versions of the file with | ||
|
||
$ git branch master # see original version of the file | ||
|
||
and | ||
|
||
$ git branch boss # see version of the file suitable for boss' eyes | ||
|
||
One can imagine reasons to use this that have nothing to do with source code management. Perhaps you have a program that reads data from a certain directory, and every now and then you'd like to switch the data back and forth without reconfiguring the program. | ||
|
||
== Dirty Work == | ||
|
||
TODO | ||
|
||
== Quick Fixes == | ||
|
||
TODO | ||
|
||
== Working While Being Reviewed == | ||
|
||
Some projects require your code to be reviewed before you can submit it. To make life easier for those reviewing your code, if you have a big change to make you might break it into two or more parts, and get each parts separately reviewed. | ||
|
||
What if the second part cannot be written until the first part is approved and checked in? In many version control systems, you'd have to send the first part to the reviewers, and then wait until it has been approved before starting on the second part. | ||
|
||
Actually that's not quite true, but in many systems editing part 2 before part 1 had been submitted involves a lot of suffering and hardship. In Git, branching and merging are painless. So after you've committed the first part and sent it for review: | ||
|
||
$ git checkout -b part2 | ||
|
||
Next, code the second part of the big change while you're waiting for the first part to be accepted. When the first part is approved and submitted, | ||
|
||
$ git branch master | ||
$ git merge part2 | ||
$ git branch -d part2 | ||
|
||
and the second part of the change is ready to review. | ||
|
||
But wait! What if it wasn't that simple? Say you made a mistake in the first part, which you have to correct before submitting. No problem! First, switch back to the master branch with <tt>git branch master</tt>. Fix the issue with the first part of the change and hope it gets approved. If not we simply repeat this step. | ||
|
||
Eventually, once the first part has been approved and submitted: | ||
|
||
$ git merge part2 | ||
|
||
and again, the second part is ready to be reviewed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
= Cloning Around = | ||
|
||
== Classic Source Control == | ||
|
||
Copy your project to a directory in your main server. Initialize a Git | ||
repository: <tt>git init ; git add . ; git commit -m "Initial commit"</tt>. | ||
|
||
To check out source, a developer types | ||
|
||
$ git clone git+ssh://main.server/directory | ||
|
||
After making changes, the code is checked in to the main server by: | ||
|
||
$ git commit -a | ||
$ git push | ||
|
||
If the main server has been updated, the latest version needs to be checked out before the push. To sync to the latest version: | ||
|
||
$ git commit -a | ||
$ git pull | ||
|
||
== Forking a Project == | ||
|
||
Sick of the way a project is being run? Think you could do a better job? | ||
|
||
First, on your server: | ||
|
||
$ git clone git+ssh://main.server/directory | ||
|
||
Then tell everyone to check out your fork of the project at your server. | ||
|
||
At any later time, you can merge in the changes from the original project with: | ||
|
||
$ git pull | ||
|
||
== Ultimate Backups == | ||
|
||
How would you like multiple tamper-proof geographically diverse redundant archives? | ||
|
||
TODO | ||
|
||
== Guerilla Version Control == | ||
|
||
TODO | ||
|
||
== Working On Features In Parallel == | ||
|
||
TODO | ||
|
||
== Source Control Engine Tools and Utilities == | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// From my own website(!) | ||
//TODO: only do this for links in the table of contents menu | ||
|
||
function find_selflink() { | ||
var a = document.links; | ||
var i = 0; | ||
while (i < a.length) { | ||
if (a[i].href == document.URL) { | ||
var c; | ||
var j; | ||
var s_new = document.createElement("span"); | ||
s_new.className = "currentlink"; | ||
c = a[i].childNodes; | ||
for (j=0; j<c.length; j++) { | ||
s_new.appendChild(c[j]); | ||
} | ||
a[i].parentNode.replaceChild(s_new, a[i]); | ||
} else { | ||
i++; | ||
} | ||
|
||
/* | ||
if (a[i].href == document.URL) { | ||
a[i].className = "currentlink"; | ||
if (0) { | ||
var s_new = document.createElement("span"); | ||
s_new.className = "currentlink"; | ||
s_new.appendChild(a[i]); | ||
a[i].parentNode.replaceChild(s_new, a[i]); | ||
} | ||
} | ||
i++; | ||
*/ | ||
} | ||
} | ||
|
||
find_selflink(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
# extract table of contents from index.html | ||
BOOKDIR=book | ||
gawk ' | ||
/<div class="toc">/ { | ||
print $0 | ||
getline #TODO: check this is the <ul> line | ||
print $0 | ||
print "<li><a href=\".\">Git Magic</a></li>" | ||
getline | ||
while (!match($0, "</div>")) { | ||
print $0 | ||
getline | ||
} | ||
print "</div>" | ||
exit | ||
} | ||
' < $BOOKDIR/index.html > toc.tmp | ||
|
||
# for every chapter... | ||
for FILE in $BOOKDIR/*.html | ||
do | ||
if [ $FILE != "$BOOKDIR/index.html" ] | ||
then | ||
# add " - Git Magic" to titles of all pages | ||
sed '/<\/title>/ s/<\/title>/ - Git Magic&/' -i $FILE | ||
# paste ToC into beginning | ||
# and add div section with class content for CSS | ||
sed '/<body/{n; r toc.tmp | ||
a <div class="content"> | ||
} ' -i $FILE | ||
sed '/^<\/body/i </div>' -i $FILE | ||
fi | ||
done | ||
|
||
# extract shell of index.html | ||
# then insert ToC and preface | ||
gawk ' | ||
/<div class="book"/ { | ||
i = 0 | ||
for(;;) { | ||
getline | ||
if (match($0, "<div")) i++; | ||
else if (match($0, "</div")) { | ||
i--; | ||
if (i < 0) break; | ||
} | ||
} | ||
sub("</div>","") | ||
} | ||
{ print } | ||
' < $BOOKDIR/index.html | sed '/<body/{n; r toc.tmp | ||
a <div class="content"> | ||
r preface.html | ||
a </div> | ||
} ' > tmp.tmp | ||
mv tmp.tmp $BOOKDIR/index.html | ||
rm toc.tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h1>Git Magic</h1> | ||
<p> | ||
Git is a version control Swiss army knife. The duct tape of source code management. A reliable versatile multipurpose tool for all your revision control needs. | ||
The tricky part is learning to use it. I'm recording what I've figured out so far in these pages. | ||
</p> | ||
<p> | ||
Rather than explain how it works, I'll provide recipes for particular tasks. After practice, you eventually figure out what's going on behind each trick. | ||
</p> | ||
<p> | ||
<a href="/~blynn/">Ben Lynn</a> | ||
</p> |
Oops, something went wrong.