1.创建github账号 :xxx
2.ubuntu系统下创建ssh秘钥:
ssh-keygen命令,然后一直默认,生成秘钥在/root/.ssh/目录下,cat id_rsa.pub,把内容复制,ssh-
rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJFedDA01DeZSVn
+2KPaCi54/Sh0kHVwAmlniOLOGovkPq64KWg9hhOzyw1YqbI/y7wbr9JJGABB7IrgypEcVeCaLthFKQkj5quCDOLRHL
5ok0h11+K5sdDLb2Iyuub1vwT8mNI3WhEj3rQjnSdJMAi0UidN1hvMbsXgTn9vNK7L5WaeRGDBbTmLI68i
+EsJECDEeOLwx7ytKs1wUlaimZ6kG53zzXOOyPRfeN8V9qfkT4rCWj9J+JyM4HvCPZk3o9uKxFWUMgiKe
+353ff6o0ne6Y0o7lkXuF2rDRBUF0mqxzMD1J04gmiJoLcJagIVptDxV12w8B8OIo1fGwUKl7 然后去github上
settings--->Deploy keys--->粘贴内容
3.回到ubuntu系统ssh -T xxx
@github.com 命令检查是否可以,如果显示Hi someone! You've
successfully authenticated, but GitHub does not provide shell access. ,说明秘钥设置成功
4.然后就可以在ubuntu系统上用git命令操作github上的代码了,常用命令如下:
git clone git://github.com:xxxx/test.git ##以gitreadonly方式克隆到本地,只可以读
git clone
git@github.com:xxx/test.git ##以SSH方式克隆到本地,可以读写
git clone
https://github.com/xxx/test.git ##以https方式克隆到本地,可以读写
git fetch
git@github.com:xxx/xxx.git ##获取到本地但不合并
git pull
git@github.com:xxx/xxx.git ##获取并合并内容到本地
5.这里我们使用的git clone
ssh://xxx@github.com/xxx/tornado.git
以ssh方式克隆到本地 ,查看本地有一个tornado目录,这时候我们可以操作目录下的代码,试着修改
一处,然后git status查看状态,发现有修改,然后我们 git commit -m 'one' 试着提交一下,这时候
报错,提示我们要设置用户名和邮箱如下:
git config --global user.name "xxx"
git config --global user.email xxx
@163.com
我们配置好用户名和邮箱后,在用命令 git commit -m 'one' 提交成功,然后查看状态
root@xxx:/git/tornado# git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
6.最后一步:push后本地修改的代码就被传到github上了
root@xxx:/git/tornado# git push origin
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 293 bytes, done.
Total 3 (delta 0), reused 0 (delta
49b4165..398bff0 master -> master