-
Notifications
You must be signed in to change notification settings - Fork 1
/
learning_git.html
242 lines (174 loc) · 9.49 KB
/
learning_git.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!--
88
"" ,d
88
,adPPYb,d8 88 MM88MMM
a8" `Y88 88 88
8b 88 88 88
"8a, ,d88 88 88,
`"YbbdP"Y8 88 "Y888
aa, ,88
"Y8bbdP"
-->
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="description" content="gumad.club : Club Website Source Code">
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/style.css">
<title>gumad.club</title>
</head>
<body>
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="inner">
<a id="forkme_banner" href="https://github.com/gu-app-club/">View on GitHub</a>
<br>
<a href="http://gumad.club" <h3 id="project_title">GU<span class="light">MAD</span> </h3> </a>
</header>
</div>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<blockquote>
<p>Learn git in 10ish minutes…</p>
</blockquote>
<h1 id="how-to-use-git">How to use git!</h1>
<p>This is an exercise to learn git. Git is basically Google Drive for developers and it’s an essential skill for working
together on a project.</p>
<p>This guide will assume you already have git installed. If you don’t, you should follow the instructions for you operating
system <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">here</a>.</p>
<p>This also assumes that you have made a github account and have been invited to the <a href="https://github.com/gu-app-club">GU-MAD organization</a> on github.</p>
<ul>
<li>If you haven’t made a github account yet, you can do so <a href="https://github.com/">here</a>.</li>
<li>If <em>you have</em> made a github account but haven’t been added to the organization, ask one of the officers (Rudy
or Evan) to add you!</li>
</ul>
<h1 id="the-rite-of-passage">The rite of passage.</h1>
<p>The goal of this rite of passage is to add your name to the <code class="highlighter-rouge">lets-learn-git</code> repository
(repo).</p>
<p>A <code class="highlighter-rouge">repository</code> is a git word for a place where your files are stored. It’s just
a folder that lives somewhere else. (like dropbox)</p>
<h3 id="cloning-the-repo">Cloning the repo</h3>
<p>We’re going to start by cloning the repository. In your terminal or your git command line, type this:</p>
<div class="highlighter-rouge">
<pre class="highlight"><code>git clone https://github.com/gu-app-club/lets-learn-git.git
</code></pre>
</div>
<p>“Cloning” a repository will download a version of it to your computer. It will call the folder <code class="highlighter-rouge">lets-learn-git</code>.
So let’s go into that folder!</p>
<div class="highlighter-rouge">
<pre class="highlight"><code>cd lets-learn-git/
</code></pre>
</div>
<h3 id="signing-your-name">Signing your name!</h3>
<p>If you <code class="highlighter-rouge">ls</code> right now, you’ll see a <code class="highlighter-rouge">README.md</code> file. The <code class="highlighter-rouge">md</code> file type is Markdown, which is a super-simple language for writing
documents. If you’ve ever done any formatting in Slack or on Reddit, it’s very similar.</p>
<p>Every github has a <code class="highlighter-rouge">README.md</code> file that it shows as its main file. If you look
at the repository <a href="https://github.com/gu-app-club/lets-learn-git">on github</a>, that’s the text you see
there.</p>
<p>Let’s open up the README. You can open it up in any text editor. I like the text editor <a href="https://atom.io/">atom</a>,
but you can use whatever you want. To open in <code class="highlighter-rouge">vim</code> for example, you would:</p>
<div class="highlighter-rouge">
<pre class="highlight"><code>vim README.md
</code></pre>
</div>
<p>Inside the file, you should see a place where it says:</p>
<div class="highlighter-rouge">
<pre class="highlight"><code># Sign your name here!
</code></pre>
</div>
<p>Add your name to the list like so:</p>
<div class="highlighter-rouge">
<pre class="highlight"><code># Sign your name here!
- Grace Hopper
</code></pre>
</div>
<p>Then save the file.</p>
<h3 id="creating-a-commit">Creating a commit!</h3>
<p>Once you’re done, go back to your command line. We’re going to upload our change to the repository!</p>
<p>We do this by creating a <code class="highlighter-rouge">commit</code>. A commit is a complete version of your code
that you’re adding. For example, every time your phone updates some app, behind the scenes, someone has pushed a
commit (which might be called something like <code class="highlighter-rouge">Add cool feature XYZ; Fix death-bug</code>).</p>
<p>The important part: <strong>A commit contains one or more file “changes”.</strong></p>
<h4 id="time-to-check-our-status">Time to check our status</h4>
<p>Before we create our commit, we should check our <code class="highlighter-rouge">status</code>. A <code class="highlighter-rouge">git status</code> is git’s way of telling you which files you’ve changed and therefore which files you could add to your commit. To
see your status, in the command line:</p>
<div class="highlighter-rouge">
<pre class="highlight"><code>git status
</code></pre>
</div>
<p>That should print out (in red) <code class="highlighter-rouge">modified</code> followed by the name of the file.</p>
<p><img src="http://i.imgur.com/7ZZdp6N.png" alt="example of git output" /></p>
<h4 id="adding-files">Adding files</h4>
<p>Hopefully it should tell you that you’ve modified your <code class="highlighter-rouge">README.md</code> file. Now let’s
add that file to our commit.</p>
<div class="highlighter-rouge">
<pre class="highlight"><code>git add README.md
</code></pre>
</div>
<p>If you call <code class="highlighter-rouge">git status</code> again, it should still say you’ve modified the file,
but this time you will see it in green!</p>
<p><img src="http://i.imgur.com/qbZxgM0.png" alt="example of git output when modified" /></p>
<h4 id="committing">Committing</h4>
<p>If we had other files, we would add them too. But we don’t, so lets bundle everything into our commit. We can do this
with:</p>
<div class="highlighter-rouge">
<pre class="highlight"><code>git commit -m "I signed my name"
</code></pre>
</div>
<p>Notice the message after <code class="highlighter-rouge">-m</code>. You can put anything here, but it’s typically expected
for you to say something about what you did.</p>
<p>If you call <code class="highlighter-rouge">git status</code> now, you should see that git tells you:</p>
<div class="highlighter-rouge">
<pre class="highlight"><code>On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
</code></pre>
</div>
<p>Notice that there are no longer any modified files. Git recognizes that the change’s we’ve made are part of the commit
that it has.</p>
<h4 id="pushing">Pushing</h4>
<p>We’re almost done! We need to <code class="highlighter-rouge">push</code> our commit to the repo on github. Right now
it only exists on our local computer. We can do this via:</p>
<div class="highlighter-rouge">
<pre class="highlight"><code>git push
</code></pre>
</div>
<p>Git will ask you for your username password. <strong>This is your github username and password</strong>, not your computer’s
username and password.</p>
<p>If all goes well, you should see something like this:</p>
<div class="highlighter-rouge">
<pre class="highlight"><code>Username for 'https://github.com': Flaque
Password for 'https://[email protected]':
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 281 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local objects.
To https://github.com/gu-app-club/lets-learn-git.git
8e10b56..aa3f7b3 master -> master
</code></pre>
</div>
<h1 id="hurrah">Hurrah!</h1>
<p><img src="http://s2.quickmeme.com/img/14/14c0f057abec6dabfc5be48cbbd0d904fef889a8781eee667984089207daf998.jpg" alt="great success"
/></p>
<p>If you go look at <a href="https://github.com/gu-app-club/lets-learn-git">the github</a>, you’ll see your name on the
list!</p>
<hr />
<h1 id="tldr">TL;DR</h1>
<p>How to push something in quick and easy steps.</p>
<ol>
<li>(if you haven’t already) clone the repo: <code class="highlighter-rouge">git clone <repo_url_here></code></li>
<li>Make changes.</li>
<li><code class="highlighter-rouge">git add *</code></li>
<li><code class="highlighter-rouge">git commit -m "message here"</code></li>
<li><code class="highlighter-rouge">git push</code></li>
</ol>
</section>
</div>
</body>
</html>