-
Notifications
You must be signed in to change notification settings - Fork 136
/
index.html
160 lines (123 loc) · 6.59 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!doctype html>
<html>
<head>
<script type="text/javascript">
// first, create the object that contains
// configuration variables
MTIConfig = {};
// next, add a variable that will control
// whether or not FOUT will be prevented
MTIConfig.EnableCustomFOUTHandler = true // true = prevent FOUT
</script>
<script type="text/javascript" src="http://fast.fonts.net/jsapi/3ac768d8-7a5c-4fd8-b377-f61d7f1760fa.js"></script>
<title>Gitlet</title>
<meta name = "viewport" content = "width = device-width">
<link type="text/css" rel="stylesheet" href="resources/main.css" />
</head>
<body>
<h1>Gitlet</h1>
<div class="links">
<a href="/docs/gitlet.html">Annotated source</a>
<a href="http://maryrosecook.com/blog/post/git-from-the-inside-out">Git from the inside out</a>
<a href="https://github.com/maryrosecook/gitlet">GitHub</a>
</div>
<hr/>
<p>
Gitlet is an implemention of Git in JavaScript.
</p>
<p>
Over the last six years, I've become better at using Git for version control.
But my conceptions of the index, the working copy, the object graph and remotes have just grown fuzzier.
</p>
<p>
Sometimes, I can only understand something by implementing it.
So, I wrote Gitlet, my own version of Git.
I pored over tutorials.
I read articles about internals.
I tried to understand how API commands work by reading the docs, then gave up and ran hundreds of experiments on repositories and rummaged through the <code>.git</code> directory to figure out the results.
</p>
<p>
I discovered that, if approached from the inside out, Git is easy to understand.
It is the product of simple ideas that, when combined, produce something very deep and beautiful.
</p>
<h2>Using Gitlet to understand Git</h2>
<h3>Preparation</h3>
<p>
For a quick introduction to what happens when you run the basic Git commands, read <a href="http://maryrosecook.com/blog/post/git-in-six-hundred-words">Git in six hundred words</a>.
</p>
<p>
For a six thousand word deep dive into the innards of Git, read <a href="http://maryrosecook.com/blog/post/git-from-the-inside-out">Git from the inside out</a>.
</p>
<h3>Annotated source</h3>
<p>
The <a href="/docs/gitlet.html">heavily annotated Gitlet source</a> is one thousand lines long.
This may sound intimidating, but it's OK.
The annotations explain both Git and the code in great detail.
The code mirrors the terminology of the Git command line interface,
so it should be approachable.
And the implementation of the main Git commands is just three hundred and fifty lines.
</p>
<h2>Getting the code</h2>
Clone it from <a href="https://github.com/maryrosecook/gitlet">GitHub</a>:
<pre><span class="output"><span class="prompt">$</span></span> git clone [email protected]:maryrosecook/gitlet.git</pre>
Or install it from <a href="https://www.npmjs.com/package/gitlet">npm</a>:
<pre><span class="output"><span class="prompt">$</span></span> npm install -g gitlet</pre>
<h2>Using Gitlet for version control</h2>
<p>
I wrote Gitlet to explain how Git works.
It would be unwise to use Gitlet to version control your projects.
But it does work. Sort of.
</p>
First, install <a href="http://nodejs.org/#download">Node.js</a>. Then:
<pre><span class="output"> <span class="prompt">$</span></span> npm install -g gitlet
<span class="output"> <span class="prompt">$</span></span> mkdir a
<span class="output"> <span class="prompt">$</span></span> cd a
<span class="output">./a <span class="prompt">$</span></span> gitlet init
<span class="output">./a <span class="prompt">$</span></span> echo first > number.txt
<span class="output">./a <span class="prompt">$</span></span> gitlet add number.txt
<span class="output">./a <span class="prompt">$</span></span> gitlet commit -m "first"
<span class="output">[master 2912d7a2] first</span>
<span class="output">./a <span class="prompt">$</span></span> cd ..
<span class="output"> <span class="prompt">$</span></span> gitlet clone a b
<span class="output"> <span class="prompt">$</span></span> cd b
<span class="output">./b <span class="prompt">$</span></span> echo second > number.txt
<span class="output">./b <span class="prompt">$</span></span> gitlet add number.txt
<span class="output">./b <span class="prompt">$</span></span> gitlet commit -m "second"
<span class="output">[master 484de172] second</span>
<span class="output"> <span class="prompt">$</span></span> cd ../a
<span class="output">./a <span class="prompt">$</span></span> gitlet remote add b ../b
<span class="output">./a <span class="prompt">$</span></span> gitlet fetch b master
<span class="output">From ../b</span>
<span class="output">Count 6</span>
<span class="output">master -> b/master</span>
<span class="output">./a <span class="prompt">$</span></span> gitlet merge FETCH_HEAD
<span class="output">Fast-forward</span>
<span class="output">./a <span class="prompt">$</span></span> gitlet branch other
<span class="output">./a <span class="prompt">$</span></span> gitlet checkout other
<span class="output">Switched to branch other</span>
<span class="output">./a <span class="prompt">$</span></span> echo third > number.txt
<span class="output">./a <span class="prompt">$</span></span> gitlet add number.txt
<span class="output">./a <span class="prompt">$</span></span> gitlet commit -m "third"
<span class="output">[other 656b332d] third</span>
<span class="output">./a <span class="prompt">$</span></span> gitlet push b other
<span class="output">To ../b</span>
<span class="output">Count 9</span>
<span class="output">other -> other</span></pre>
<h2>Running the tests</h2>
Install <a href="http://nodejs.org/#download">Node.js</a>.
<pre>
<span class="output"><span class="prompt">$</span></span> git clone [email protected]:maryrosecook/gitlet.git
<span class="output"><span class="prompt">$</span></span> cd gitlet
<span class="output"><span class="prompt">$</span></span> npm install
<span class="output"><span class="prompt">$</span></span> npm test
</pre>
<h2>Licence</h2>
<p>
The <a href='http://github.com/maryrosecook/gitlet'>code</a> is open source, under the <a href='http://en.wikipedia.org/wiki/MIT_License'>MIT licence</a>.
</p>
<hr/>
<div class="footer">
By <a href="http://maryrosecook.com">Mary Rose Cook</a> at the <a href="https://www.recurse.com">Recurse Center</a>
</div>
</body>
</html>