diff options
| author | Cameron McEfee <cameron@github.com> | 2011-02-25 13:26:21 -0800 |
|---|---|---|
| committer | Cameron McEfee <cameron@github.com> | 2011-02-25 13:26:21 -0800 |
| commit | 521fb3dc5de606114ac5cebbb654336492d7461f (patch) | |
| tree | 9785203597d8c904927a452f8a854d0fdfa227f5 /_posts/2011-02-15-mac-set-up-git.markdown | |
| parent | 24e997a7789019de6c0d39dfd76660557c1a78e3 (diff) | |
commit before deleting the 'explain it' styles
Diffstat (limited to '_posts/2011-02-15-mac-set-up-git.markdown')
| -rw-r--r-- | _posts/2011-02-15-mac-set-up-git.markdown | 146 |
1 files changed, 87 insertions, 59 deletions
diff --git a/_posts/2011-02-15-mac-set-up-git.markdown b/_posts/2011-02-15-mac-set-up-git.markdown index a4d3ef6..a35e587 100644 --- a/_posts/2011-02-15-mac-set-up-git.markdown +++ b/_posts/2011-02-15-mac-set-up-git.markdown @@ -18,119 +18,147 @@ _*If you don’t already know what Git is, <a href="http://progit.org/bo ##<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 involves a number of steps. +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 Terminal.app, usually found at /Applications/Utilities. <img src="/images/bootcamp/bootcamp_1_mac_terminal.jpg" width="558" height="200" alt="Open the terminal" /> -<p> -<span class="explain">Need a quick lesson on Terminal? - <span class="explain-it-shell"><span class="triangle"> </span><span class="explain-it">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 comes with your Mac called Terminal.app. A line that begins with the dollar sign ($) indicates a line of code you need to type. To enter it, type the text that follows the $, hitting the return key at the end of each line. If you see a line in an example that doesn’t begin with a $ (we’ve made them <span class="terminal-output">green</span> in the bootcamp tutorials), that means it is a line of text that terminal has output for you to read and/or act upon. In the bootcamp examples, you can roll over the lines of Bash script for an explanation of what they do.<br/><br/> +<div class="more-info"> + <h4 class="compressed">Need a quick lesson about Terminal?</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 comes with Linux called Terminal.</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 to see 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 quote marks.</span></span> + </pre> + + <p>Areas of yellow text represent your own personal info. If it is part of an input ($) line, you should replace your 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 Terminal</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 the Terminal don’t have any output. Don’t worry, if there is ever a problem with your code, Terminal will let you know.</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 the Terminal don’t have any output. Don’t worry, if there is ever a problem with your code, Terminal will let you know.<br/><br/> - - <strong>Good to know</strong>: For security reasons, Terminal will not display what you type when entering passwords. Just type your password and hit the return key. - </span></span> -</span> -</p> + <p><strong>Good to know</strong>: For security reasons, Terminal 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 class="terminal-tooltip">Checks to see if there is a folder named ".ssh" in you user directory</span></span> + <span class="codeline">$ cd ~/.ssh<span>Checks to see if there is a folder named ".ssh" in you user directory</span></span> </pre> - <p class="short-bottom-marg">Does it say "No such file or directory"?</p> - <p class="next-step"><strong>No:</strong> Go to Step 2<br /><strong>Yes:</strong> Skip to Step 3 - </p> + 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 it up and remove it: <pre class="terminal bootcamp"> - <span class="codeline">$ ls<span class="terminal-tooltip">Lists all the subdirectories in the current directory</span></span> - <span class="terminal-output codeline">config id_rsa id_rsa.pub known_hosts</span> - <span class="codeline">$ mkdir key_backup<span class="terminal-tooltip">Makes a folder called "key_backup" in the current directory</span></span> - <span class="codeline">$ cp id_rsa* key_backup<span class="terminal-tooltip">Copies the contents of the id_rsa folder into key_backup folder</span></span> - <span class="codeline">$ rm id_rsa*<span class="terminal-tooltip">Deletes the contents of the id_rsa folder</span></span> + <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 folder 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 folder into key_backup folder</span></span> + <span class="codeline">$ rm id_rsa*<span>Deletes the contents of the id_rsa folder</span></span> </pre> 3. <span class="step-title">Generate a new SSH key.</span> - To generate a new SSH key, enter the code below. When asked to enter a file in which to save the key, just press enter without typing anything. + 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>your_email@youremail.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 (/Users/<em>your_user_directory</em>/.ssh/id_rsa):</span> + </pre> + + Now you need to enter a passphrase. _[Why is this important?](../working-with-key-passphrases)_ <pre class="terminal bootcamp"> - <span class="codeline">$ ssh-keygen -t rsa -C "octocat@github.com"<span class="terminal-tooltip">Creates a new ssh key using the provided email</span></span> - <span class="terminal-output codeline">Generating public/private rsa key pair.</span> - <span class="terminal-output codeline">Enter file in which to save the key (/Users/octocat/.ssh/id_rsa):</span> - <span class="terminal-output codeline">Enter passphrase (empty for no passphrase):</span> - <span class="terminal-output codeline">Enter same passphrase again:</span> + <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="terminal-output codeline">Your identification has been saved in /Users/octocat/.ssh/id_rsa.</span> - <span class="terminal-output codeline">Your public key has been saved in /Users/octocat/.ssh/id_rsa.pub.</span> - <span class="terminal-output codeline">The key fingerprint is:</span> - <span class="terminal-output codeline">01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db octocat@github.com</span> - <span class="terminal-output codeline">The key's randomart image is:</span> - <span class="terminal-output codeline">+--[ RSA 2048]----+</span> - <span class="terminal-output codeline">| .+ + |</span> - <span class="terminal-output codeline">| = o O . |</span> - <span class="terminal-output codeline">| = * * |</span> - <span class="terminal-output codeline">| o = + |</span> - <span class="terminal-output codeline">| o S . |</span> - <span class="terminal-output codeline">| o o = |</span> - <span class="terminal-output codeline">| o . E |</span> - <span class="terminal-output codeline">| |</span> - <span class="terminal-output codeline">| |</span> - <span class="terminal-output codeline">+-----------------+</span> + <span class="bash-output">Your identification has been saved in /Users/<em>your_user_directory</em>/.ssh/id_rsa.</span> + <span class="bash-output">Your public key has been saved in /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> + <span class="bash-output">The key's randomart image is:</span> + <span class="bash-output">+--[ RSA 2048]----+</span> + <span class="bash-output">| .+ + |</span> + <span class="bash-output">| = o O . |</span> + <span class="bash-output">| = * * |</span> + <span class="bash-output">| o = + |</span> + <span class="bash-output">| o S . |</span> + <span class="bash-output">| o o = |</span> + <span class="bash-output">| o . E |</span> + <span class="bash-output">| |</span> + <span class="bash-output">| |</span> + <span class="bash-output">+-----------------+</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”_ - It’s important you copy your SSH key exactly as it is written without adding any newlines or whitespace. To ensure this, run the following code to copy the key to your clipboard. + __It’s important you copy your SSH key exactly as it is written without adding any newlines or whitespace.__ To ensure this, run the following code to copy the key to your clipboard. <pre class="terminal bootcamp"> - <span class="codeline">$ cat ~/.ssh/id_rsa.pub | pbcopy<span class="terminal-tooltip">Copies the contents of the id_rsa.pub file to your clipboard</span></span> + <span class="codeline">$ cat ~/.ssh/id_rsa.pub | pbcopy<span>Copies the contents of the id_rsa.pub file to your clipboard</span></span> </pre> - Now paste it into the “Key” field + Now paste it into the “Key” field. - <img src="/images/bootcamp/bootcamp_1_ssh.jpg" width="558" height="373" alt="Paste your SSH Key" /> + <img src="/images/bootcamp/bootcamp_1_ssh.jpg" width="558" height="402" alt="Paste your SSH Key" /> - Hit “Add 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: + 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 class="terminal-tooltip">Attempts to ssh to github</span></span> + <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="terminal-output codeline">The authenticity of host 'github.com (207.97.227.239)' can't be established.</span> - <span class="terminal-output codeline">RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.</span> - <span class="terminal-output codeline">Are you sure you want to continue connecting (yes/no)?</span> + <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="terminal-output codeline">Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.</span> - <span class="terminal-output codeline">ERROR: Hi octocat! You've successfully authenticated, but GitHub does not provide <br />shell access</span> - <span class="terminal-output codeline">Connection to github.com closed.</span> + <span class="bash-output">Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.</span> + <span class="bash-output">ERROR: Hi <em>username</em>! You've successfully authenticated, but GitHub does not provide <br />shell access</span> + <span class="bash-output">Connection to github.com closed.</span> </pre> + You don’t worry, about the “ERROR”. You actually want to see that. + + ##<span>Then: </span> Set Up Your Info Now that you have Git set up and your SSH keys entered in GitHub, it’s time to configure your personal info. @@ -140,23 +168,23 @@ Now that you have Git set up and your SSH keys entered in GitHub, it’s tim 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 "The Octocat"<span class="terminal-tooltip">Sets the name of the user for all git instances on the system</span></span> - <span class="codeline">$ git config --global user.email "octocat@github.com"<span class="terminal-tooltip">Sets the email of the user for all git instances on the system</span></span> + <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>your_email@youremail.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”_ + 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 Terminal, 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 octocat<span class="terminal-tooltip">Sets the GitHub username for all git instances on the system</span></span> - <span class="codeline">$ git config --global github.token 0123456789abcdef0123456789abcdef<span class="terminal-tooltip">Sets the GitHub token for all git instances on the system</span></span> + <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>0123456789yourf0123456789token</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. |
