http://jingyan.baidu.com/article/ab0b5630936ab6c15afa7d1c.html

https://help.github.com/articles/generating-ssh-keys/

  

今天为了把项目挂到Github上并且和组员协作好,研究了下Github的使用方法,现在做个总结记录下来。

1.添加ssh-key(该部分转自Github官网https://help.github.com/articles/generating-ssh-keys

Step 1: Check for SSH keys

Have an existing keypair you'd like to use? You can skip to Step 4.

First, we need to check for existing ssh keys on your computer. Open up Terminal and run:

cd ~/.ssh# Checks to see if there is a directory named ".ssh" in your user directory

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

Step 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# Lists all the subdirectories in the current directory
# config id_rsa id_rsa.pub known_hosts mkdir key_backup# Makes a subdirectory called "key_backup" in the current directory cp id_rsa* key_backup# Copies the id_rsa keypair into key_backup rm id_rsa*# Deletes the id_rsa keypair

Step 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@example.com"# Creates a new ssh key using the provided email
# Generating public/private rsa key pair.
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]

Now you need to enter a passphrase.

# Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]

Which should give you something like this:

# Your identification has been saved in /Users/you/.ssh/id_rsa.
# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

Step 4: Add your SSH key to GitHub

Run the following code to copy the key to your clipboard.

pbcopy < ~/.ssh/id_rsa.pub# Copies the contents of the id_rsa.pub file to your clipboard

Be warned: it is important to copy the key exactly without adding newlines or whitespace. Thankfully the pbcopy command makes it easy to perform this setup perfectly.

  1. Go to your Account Settings
  2. Click "SSH Keys" in the left sidebar
  3. Click "Add SSH key"
  4. Paste your key into the "Key" field
  5. Click "Add key"
  6. Confirm the action by entering your GitHub password

Step 5: Test everything out

To make sure everything is working you'll now SSH to GitHub. When you do this, you will be asked to authenticate this action using your password, which for this purpose is the passphrase you created earlier. Don't change the git@github.com part. That's supposed to be there.

ssh -T git@github.com# Attempts to ssh to github

You may see this warning:

# 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. Verify that the fingerprint matches the one here and type "yes".

# Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.

If that username is correct, you've successfully set up your SSH key. Don't worry about the shell access thing, you don't want that anyway.

If you see "access denied" please consider using HTTPS instead of SSH. If you need SSH start atthese instructions for diagnosing the issue.

2.新建仓库

2.1 在Github上登陆自己的账号点击右上方的Create New Repo

2.2 填写好自己的仓库名,(例如CSDNTest)

2.3Github上新建好仓库后在命令行运行如下指令(学过Git的应该知道是什么意思)

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:chenyl107/CSDNTest.git
git push -u origin master

3.添加协作者

你的仓库-->setting-->Collaborators,然后输入你的协作者的用户名 add就可以了

 

Github使用总结(添加ssh-key,新建仓库,添加协作者) 转的更多相关文章

  1. 为github添加ssh key

    用git关联github上的远程仓库前需要先为github添加ssh key 一.检查本机是否生成ssh key 本地查找.ssh文件,其中id_rsa.pub中的内容就是ssh key 二.为git ...

  2. windows系统如何添加ssh key到github

    我自己的电脑安装了git后,从来没有用过,今天偶然用了一次,发现不能pull到东西,报错说我没有权限,于是我网上搜索了一下,应该是我没有配置ssh key的原因,相信很多人都有和我一样的经历吧,这里呢 ...

  3. github 添加 SSH key

    在 github 上添加 SSH key 的步骤: 1.首先需要检查你电脑是否已经有 SSH key 运行 git Bash 客户端,输入如下代码: $ cd ~/.ssh $ ls 这两个命令就是检 ...

  4. github添加ssh key报错Key is invalid. Ensure you've copied the file correctly

    github添加ssh key的时候报错:Key is invalid. Ensure you've copied the file correctly 将秘钥复制粘贴到文本编辑器中,再粘贴复制到

  5. github添加SSH Key

    1.背景介绍 缘由:在github上下载goagent时出现错误. 在终端使用命令:git clone git@github.com:phuslu/goagent.git 会报权限错误如下: Clon ...

  6. (诊断)为GitHub添加SSH key时出现“Could not open a connection to your authentication agent”错误的应对方案(转)

    在为windows 环境下的github账户添加SSH key时,需要在Git Bash执行如下命令: 第一步:检查已有的SSH keys $ ls -al ~/.ssh 第二步:生成新的SSH ke ...

  7. github入门:设置添加ssh key<转>

    GitHub是个分布式的版本控制库.github通过git使用,可以方便的记录代码版本. 通过github可以学习优秀的代码,可以改进提交其他项目中的bug,借助社区力量促进软件优化完善. 国内外大量 ...

  8. git生成ssh key步骤并添加到github网站

    0: 查看是否已经有了ssh密钥 执行命令:cd ~/.ssh 如果没有密钥则不会有此文件夹,有则备份删除 1:使用 Git Bash生成新的ssh key ssh-keygen -t rsa -C  ...

  9. 如何给 GitHub 添加 SSH key, 如何生成 SSH key 详细图文教程!

    如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程! 一. 生成  SSH key https://ide.c9.io/xgqfrms/ 创建一个空项目:(或使用 ...

  10. 多github帐号的SSH key切换

    我有两个github帐号,一个是个人所用,一个是为公司项目所用.如果是单用户(single-user),很方便,默认拿id_rsa与你的github服务器的公钥对比:如果是多用户(multi-user ...

随机推荐

  1. Linux shell--基础指令

    Linux shell--基础指令 浏览Linux文件系统 Linux中最基础也是最必要的一条指令 cd destination cd命令可接受单个参数destination,用以指定想切换到的目录名 ...

  2. hadoop免登录

    参考:http://wenku.baidu.com/link?url=n4PT7AhGnV7N8KevSEAMcCVGEaYqTuKmNodCQsUnR7qtAnWM0WDs8pFYLOpCUu9R9 ...

  3. Linux下使用 github+hexo 搭建个人博客06-next主题接入数据统计

    之前说了 next 主题的优化和接入评论系统.让我们完成了自己所需的页面风格和排版,也可让访问用户在每篇博文评论,完成博主和访问用户的交互. 本章我们继续讲解其他重要功能. 既然是一个网站,那么我们就 ...

  4. mongodb4版本,windows下的安装与配置(史上步骤最全最详细+图解)

    安装的是4.2.1版本,安装途中出现过很多错误,找遍各种博客基本没能解决 1.mongodb安装的官方地址: https://www.mongodb.com/download-center/commu ...

  5. 更改 undo_retention 时,Lob retention 不更改 (Doc ID 563470.1)

    Lob retention not changing when undo_retention is changed (Doc ID 563470.1) APPLIES TO: Oracle Datab ...

  6. 如何快速查看 group 对应的id

    最近需要获取group 对应的id 数字号码,突然想不起来怎么获得了,现在在这里进行备忘一下: $ cut -d: -f3 < <(getent group sudo) getent gr ...

  7. gcd套路变换

    gcd套路变换 GCD https://www.luogu.org/problem/P2568 给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. $ 1& ...

  8. vue项目中引入特殊字体

    特殊字体指的是默认电脑中没有的 1.下载字体 2.新建文件夹font,把字体放进去 3.新建font.css 4.使用@font-face设置字体 @font-face { font-family: ...

  9. NOIP 2012 文化之旅

    洛谷 P1078 文化之旅 洛谷传送门 JDOJ 1788: [NOIP2012]文化之旅 T4 JDOJ传送门 Description Input Output Sample Input Input ...

  10. python第一次作业-Numpy练习

    1.创建一个边界值为1而内部都是0的数组,图例如下:[提示:]解此题可以先把所有值都设置为1,这是大正方形:其次,把边界除外小正方形全部设置为0.本题用到numpy的切片原理.多维数组同样遵循x[st ...