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
|
---
layout: default
title: Set Up Git (Windows)
description: A quick guide to help you get started with Git
categories: windows
---
<span class="intro">If you’ve found yourself on this page, we’re assuming you’re brand new to Git and GitHub. This guide will walk you through the basics and explain a little bit about how everything works along the way.</span>
##<span>First:</span> Download and Install Git
At the heart of GitHub is an open source version control system (VCS) called Git*. Created by the same dudes that created Linux, Git is responsible for everything GitHub related that happens locally on your computer.
_*If you don’t already know what Git is, <a href="http://progit.org/book/ch1-3.html" target="_blank">take a crash course.</a>_
1. <span class="step-title">Download and install the latest version of <a href="http://code.google.com/p/msysgit/downloads/list" target="_blank">msysgit</a>.</span>
Use the default options for each step.
<img src="/images/bootcamp/bootcamp_1_win_install_1.jpg" width="558" height="442" alt="Welcome page" />
<img src="/images/bootcamp/bootcamp_1_win_install_2.jpg" width="558" height="442" alt="Information" />
<img src="/images/bootcamp/bootcamp_1_win_install_3.jpg" width="558" height="442" alt="Select destination location" />
<img src="/images/bootcamp/bootcamp_1_win_install_4.jpg" width="558" height="442" alt="Select start menu folder" />
<img src="/images/bootcamp/bootcamp_1_win_install_5.jpg" width="558" height="442" alt="Select components" />
<img src="/images/bootcamp/bootcamp_1_win_install_6.jpg" width="558" height="442" alt="Adjusting your PATH environment" />
<img src="/images/bootcamp/bootcamp_1_win_install_7.jpg" width="558" height="442" alt="Configuring the line ending conversions" />
<img src="/images/bootcamp/bootcamp_1_win_install_8.jpg" width="558" height="442" alt="Installing" />
<img src="/images/bootcamp/bootcamp_1_win_install_9.jpg" width="558" height="442" alt="Installation complete" />
__Do not use PuTTY if you are given the option. GitHub only provides support for openssh.__
##<span>Next:</span> Set Up SSH Keys
We use SSH keys to establish a secure connection between your computer and GitHub. Setting them up is fairly easy, but does involve a number of steps.
To make sure you generate a brand new key, you need to check if one already exists. First, you need to open Git Bash (not the Windows command line), found in the start menu in the git.
<img src="/images/bootcamp/bootcamp_1_win_gitbash.jpg" width="558" height="300" alt="Open the terminal" />
<div class="more-info">
<h4 class="compressed">Need a quick lesson about Git Bash?</h4>
<div class="more-content">
<p>Code blocks like those on this page are part of a scripting language called Bash. To use Bash scripts, we need to use an application that was installed with Git called Git Bash.</p>
<h4>Input</h4>
<pre class="terminal bootcamp">
<span class="codeline">$ echo 'This is input text'<span>This tooltip tells you what's going on.</span></span>
</pre>
<p>A line that begins with the dollar sign ($) indicates a line of Bash script you need to type. To enter it, type the text that follows the $, hitting the return key at the end of each line. You can hover your mouse over each line for an explanation of what the script is doing.</p>
<h4>Output</h4>
<pre class="terminal bootcamp">
<span class="bash-output">This is output text.</span>
</pre>
<p>A line that does not begin with a $ is output text that is intended to give you information or tell you what to do next. We’ve colored output text green in these bootcamp tutorials.</p>
<h4>User Specific Input</h4>
<pre class="terminal bootcamp">
<span class="codeline">$ echo '<em>username</em>'<span>Outputs the text in the quotation marks.</span></span>
</pre>
<p>Areas of yellow text represent your own personal info, repos, etc. If it is part of an input ($) line, you should replace it with your own info when you type it. If it is part of output text, it is just for your reference. It will automatically show your own info in Git Bash.</p>
<p><strong>Good to know</strong>: There will be times when you type code, hit return, and all you are given is another prompt. Some actions that you execute in Git Bash don’t have any output. Don’t worry, if there is ever a problem with your code, Git Bash will let you know.</p>
<p><strong>Good to know</strong>: For security reasons, Git Bash will not display what you type when entering passwords. Just type your password and hit the return key.</p>
</div>
</div>
1. <span class="step-title">Check for SSH keys. <span>Have an existing kepair? You can skip to Step 4.</span></span>
First, we need to check for existing ssh keys on your computer:
<pre class="terminal bootcamp">
<span class="codeline">$ cd ~/.ssh<span>Checks to see if there is a directory named ".ssh" in your user directory</span></span>
</pre>
If it says “No such file or directory“ skip to __step 3__. Otherwise continue to __step 2__.
2. <span class="step-title">Backup and remove existing SSH keys.</span>
Since there is already an SSH directory you’ll want to back the old one up and remove it:
<pre class="terminal bootcamp">
<span class="codeline">$ ls<span>Lists all the subdirectories in the current directory</span></span>
<span class="bash-output">config id_rsa id_rsa.pub known_hosts</span>
<span class="codeline">$ mkdir key_backup<span>makes a subdirectory called "key_backup" in the current directory</span></span>
<span class="codeline">$ cp id_rsa* key_backup<span>Copies the contents of the id_rsa directory into key_backup directory</span></span>
<span class="codeline">$ rm id_rsa*<span>Deletes the contents of the id_rsa directory</span></span>
</pre>
3. <span class="step-title">Generate a new SSH key.</span>
To generate a new SSH key, enter the code below. We want the default settings so when asked to enter a file in which to save the key, just press enter.
<pre class="terminal bootcamp">
<span class="codeline">$ ssh-keygen -t rsa -C "<em>user_name@username.com</em>"<span>Creates a new ssh key using the provided email</span></span>
<span class="bash-output">Generating public/private rsa key pair.</span>
<span class="bash-output">Enter file in which to save the key (/c/Users/<em>your_user_directory</em>/.ssh/id_rsa):</span>
</pre>
Now you need to enter a passphrase.
<div class="more-info">
<h4 class="compressed">Why do passphrases matter?</h4>
<div class="more-content">
<p>Passwords aren’t very secure, you already know this. If you use one that’s easy to remember, it’s easier to guess or brute-force (try many options until one works). If you use one that’s random it’s hard to remember, and thus you’re more inclined to write the password down. Both of these are Very Bad Things™. This is why you’re using ssh keys.</p>
<p>But using a key without a passphrase is basically the same as writing down that random password in a file on your computer. Anyone who gains access to your drive has gained access to every system you use that key with. This is also a Very Bad Thing™. The solution is obvious: add a passphrase.</p>
<p><em>But I don’t want to enter a long passphrase every time I use the key!</em></p>
<p>Neither do we! Thankfully, there’s a nifty little tool called <code>ssh-agent</code> that can save your passphrase securely so you don’t have to re-enter it. Unfortunately, it takes a little work to get it up and running on Windows. For more information check out our <a href="/working-with-key-passphrases">help guide</a>.</p>
</div>
</div>
<pre class="terminal bootcamp">
<span class="bash-output">Enter passphrase (empty for no passphrase):</span>
<span class="bash-output">Enter same passphrase again:</span>
</pre>
Which should give you something like this:
<pre class="terminal bootcamp">
<span class="bash-output">Your identification has been saved in /c/Users/<em>your_user_directory</em>/.ssh/id_rsa.</span>
<span class="bash-output">Your public key has been saved in /c/Users/<em>your_user_directory</em>/.ssh/id_rsa.pub.</span>
<span class="bash-output">The key fingerprint is:</span>
<span class="bash-output">01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db <em>user_name@username.com</em></span>
</pre>
4. <span class="step-title">Add your SSH key to GitHub.</span>
On the GitHub site _Click “Account Settings”_ > _Click “SSH Public Keys”_ > _Click “Add another public key”_
Open the id_rsa.pub file with a text editor (Notepad will do just fine). This is your SSH key. __It’s important you copy your SSH key exactly as it is written without adding any newlines or whitespace.__ Now paste it into the “Key” field.
<img src="/images/bootcamp/bootcamp_1_ssh.jpg" width="558" height="402" alt="Paste your SSH Key" />
Hit “Add Key.”
5. <span class="step-title">Test everything out.</span>
To make sure everything is working you’ll now SSH to GitHub. Don’t change the “git@github.com” part. That’s supposed to be there.
<pre class="terminal bootcamp">
<span class="codeline">$ ssh git@github.com<span>Attempts to ssh to github</span></span>
</pre>
Which should give you this:
<pre class="terminal bootcamp">
<span class="bash-output">The authenticity of host 'github.com (207.97.227.239)' can't be established.</span>
<span class="bash-output">RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.</span>
<span class="bash-output">Are you sure you want to continue connecting (yes/no)?</span>
</pre>
Don’t worry, this is supposed to happen. Type “yes”.
<pre class="terminal bootcamp">
<span class="bash-output">PTY allocation request failed on channel 0</span>
<span class="bash-output">Hi <em>username</em>! You've successfully authenticated, but GitHub does not provide shell access.</span>
<span class="bash-output">Connection to github.com closed.</span>
</pre>
Don’t worry, about the “failed” part. All you should care about is that you see “You’ve successfully authenticated”
##<span>Then: </span> Set Up Your Info
Now that you have Git set up and your SSH keys entered into GitHub, it’s time to configure your personal info.
1. <span class="step-title">Set your username and email.</span>
Git tracks who makes each commit by checking the user’s name and email. In addition, we use this info to associate your commits with your GitHub account. To set these, enter the code below, replacing the name and email with your own. The name should be your _actual name_, not your GitHub username.
<pre class="terminal bootcamp">
<span class="codeline">$ git config --global user.name "<em>Firstname Lastname</em>"<span>Sets the name of the user for all git instances on the system</span></span>
<span class="codeline">$ git config --global user.email "<em>user_name@username.com</em>"<span>Sets the email of the user for all git instances on the system</span></span>
</pre>
2. <span class="step-title">Set your GitHub token.</span>
Some tools connect to GitHub without SSH. To use these tools properly you need to find and configure your API Token.
On the GitHub site _Click “Account Settings”_ > _Click “Account Admin.”_
<img src="/images/bootcamp/bootcamp_1_token.jpg" width="558" height="245" alt="Copy your API token" />
In Git Bash, run the following code, using your GitHub username and token in place of the ones shown.
<pre class="terminal bootcamp">
<span class="codeline">$ git config --global github.user <em>username</em><span>Sets the GitHub username for all git instances on the system</span></span>
<span class="codeline">$ git config --global github.token <em>0123456789your0123456789token</em><span>Sets the GitHub token for all git instances on the system</span></span>
</pre>
__*Note*__ If you ever change your GitHub password, a new token will be created and will need to be updated.
##<span>Lastly:</span> Celebrate
Congratulations, you now have Git and GitHub all set up! What do you want to do next?
<ol class="next-steps">
<li>Set Up Git</li>
<li><a href="/create-a-repo/">Create A Repository</a></li>
<li><a href="/fork-a-repo/">Fork A Repository</a></li>
<li><a href="/be-social/">Be Social</a></li>
</ol>
|