using git by github

首先在本地创建ssh key;

1
$ssh-keygen-t rsa -C "your_email@youremail.com"

后面的your_email@youremail.com改为你的邮箱,之后会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key。

回到github,进入Account Settings,左边选择SSH Keys,Add SSH Key,title随便填,粘贴key。为了验证是否成功,在git bash下输入:

1
$ssh-T git@github.com

如果是第一次的会提示是否continue,输入yes就会看到:You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。

接下来我们要做的就是把本地仓库传到github上去,在此之前还需要设置username和email,因为github每次commit都会记录他们。

1
2
$ git config --global user.name "your name"
$ git config --global user.email "your_email@youremail.com"

Create a new repository on the command line

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/username/mygitrep.git
git push -u origin master

Push an existing repository from the command line

git remote add origin https://github.com/username/mygitrep.git
git push -u origin master
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值