码迷,mamicode.com
首页 > 其他好文 > 详细

新机git简单配置

时间:2017-11-17 11:59:39      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:terminal   opera   white   密码   log   match   ssh key   inf   min   

 

新机git简单配置,毕竟不常用,不用每次都查
1、安装git
windows:https://git-scm.com/download/win
ubuntu: apt install git

2、全局配置

git config --global user.name "you_name"
git config --global user.email "your_email@gmail.com"


3、生成ssh-key
ssh-keygen -t rsa -b 4096 -C "your_email@gmail.com"

4、添加ssh到github 以后不用每次都输入邮箱及密码
cat ~/.ssh/id_rsa.pub
把输出的内容拷贝到github上
github 在https://github.com/settings/keys
点击左上角 New SSH key 把刚才的内容复制到下面的框里,点击Add SSH key

5、可以clone你自己的代码 然后修改提交了

 

参考:

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

  1. Open Terminal.

  2. Paste the text below, substituting in your GitHub email address.

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    

    This creates a new ssh key, using the provided email as a label.

    Generating public/private rsa key pair.
    
  3. When you‘re prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

    Enter a file in which to save the key (/home/you/.ssh/id_rsa): [Press enter]
    
  4. At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".
    Enter passphrase (empty for no passphrase): [Type a passphrase]
    Enter same passphrase again: [Type passphrase again]
    

https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

Note: DSA keys were deprecated in OpenSSH 7.0. If your operating system uses OpenSSH, you‘ll need to use an alternate type of key when setting up SSH, such as an RSA key. For instance, if your operating system is MacOS Sierra, you can set up SSH using an RSA key.

  1. Copy the SSH key to your clipboard.

    If your SSH key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don‘t add any newlines or whitespace.

    $ sudo apt-get install xclip
    # Downloads and installs xclip. If you don‘t have `apt-get`, you might need to use another installer (like `yum`)
    
    $ xclip -sel clip < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard
    

    Tip: If xclip isn‘t working, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.

  2. 技术分享In the upper-right corner of any page, click your profile photo, then click Settings.

  3. 技术分享In the user settings sidebar, click SSH and GPG keys.

  4. 技术分享Click New SSH key or Add SSH key.

  5. In the "Title" field, add a descriptive label for the new key. For example, if you‘re using a personal Mac, you might call this key "Personal MacBook Air".
  6. 技术分享Paste your key into the "Key" field.
  7. 技术分享Click Add SSH key.
  8. 技术分享If prompted, confirm your GitHub password.

新机git简单配置

标签:terminal   opera   white   密码   log   match   ssh key   inf   min   

原文地址:http://www.cnblogs.com/zhishuai/p/7850595.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!