注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

伯纳乌の夢

可以挽回么?我们按“ Ctrl+Z”撤销掉吧。对不起啦~~

 
 
 

日志

 
 
 
 

[Fw]Set Up Git (Windows)  

2011-05-06 22:48:53|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
[Trackback]http://help.github.com/win-set-up-git/

Set Up Git (Windows)

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.

First: 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, take a crash course.

  1. Download and install the latest version of msysgit.

    Use the default options for each step.

    Welcome pageInformationSelect destination locationSelect start menu folderSelect componentsAdjusting your PATH environmentConfiguring the line ending conversionsInstallingInstallation complete

    Do not use PuTTY if you are given the option. GitHub only provides support for openssh.

Next: 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.

Open the terminal

Need a quick lesson about Git Bash?

  1. Check for SSH keys. Have an existing kepair? You can skip to Step 4.

    First, we need to check for existing ssh keys on your computer:

    $ cd ~/.ssh 

    If it says “No such file or directory“ skip to step 3. Otherwise continue to step 2.

  2. Backup and remove existing SSH keys.

    Since there is already an SSH directory you’ll want to back the old one up and remove it:

    $ ls config id_rsa id_rsa.pub known_hosts $ mkdir key_backup $ cp id_rsa* key_backup $ rm id_rsa* 
  3. Generate a new SSH key.

    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.

    $ ssh-keygen -t rsa -C "your_email@youremail.com" Generating public/private rsa key pair. Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):<press enter> 

    Now you need to enter a passphrase.

    Why do passphrases matter?

    Enter passphrase (empty for no passphrase):<enter a passphrase> Enter same passphrase again:<enter passphrase again> 

    Which should give you something like this:

    Your identification has been saved in /Users/your_user_directory/.ssh/id_rsa. Your public key has been saved in /Users/your_user_directory/.ssh/id_rsa.pub. The key fingerprint is: 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db user_name@username.com The key's randomart image is: +--[ RSA 2048]----+ |     .+   +      | |       = o O .   | |        = * *    | |       o = +     | |      o S .      | |     o o =       | |      o . E      | |                 | |                 | +-----------------+ 
  4. Add your SSH key to GitHub.

    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, TextEdit, or gedit will do just fine). This is your public SSH key. You may need turn on “view hidden files” to find it because the .ssh directory is hidden. 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.

    Can’t view hidden files? Other ways to copy:

    Now paste it into the “Key” field.

    Paste your SSH Key

    Hit “Add Key.”

  5. Test everything out.

    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.

    $ ssh git@github.com 

    Which should give you this:

    The authenticity of host 'github.com (207.97.227.239)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? 

    Don’t worry, this is supposed to happen. Type “yes”.

    PTY allocation request failed on channel 0 Hi username! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed. 

    Having problems?

Then: 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. Set your username and email.

    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.

     $ git config --global user.name "Firstname Lastname"  $ git config --global user.email "your_email@youremail.com" 

    More about user info

  2. Set your GitHub token.

    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.”

    Copy your API token

    At the command line run the following code, using your GitHub username and token in place of the ones shown.

     $ git config --global github.user username  $ git config --global github.token 0123456789yourf0123456789token 

    *Note* If you ever change your GitHub password, a new token will be created and will need to be updated.

Lastly: Celebrate

Congratulations, you now have Git and GitHub all set up! What do you want to do next?

  1. Set Up Git
  2. Create A Repository
  3. Fork A Repository
  4. Be Social
  评论这张
 
阅读(1081)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017