从Linux 上传代码到github

134次阅读
没有评论

共计 693 个字符,预计需要花费 2 分钟才能阅读完成。

1.本地生成密钥

ssh-keygen -t rsa -C "注册Github用的邮箱"

生成完以后

cd ~/.ssh 

cat id_rsa.pub

获得一串密钥

从Linux 上传代码到github

然后拿着这一串密钥到GitHub主页 SSH and GPG keys 添加New Key

 从Linux 上传代码到github

Title 随便填 ,key的话就把AAAA开始到邮箱结尾全部复制

 从Linux 上传代码到github

 

2.登陆并git init 初始化

如果之前的密钥没有问题的话,使用命令登陆:

 

ssh -v git@github.com

 

 

ssh -T git@github.com

从Linux 上传代码到github

初始化一个git 仓库

git init

 

从Linux 上传代码到github

 

3.git clone / git  remote add

git clone 一个project,远程仓库是配置好的。

git clone https://github.com/...

 也可以自己使用命令

git remote add origin https://github.com/frankchen121212/项目名

4.项目完成后执行git add . 添加要上传的文件

例:

添加全部文件

git add .

 添加一个文件

git add helloworld.py

 

5.提交 git commit -m "描述信息"

例:

git commit -m "This is the hello world code"

 

6.git push 上传到 branch (默认为master)

git push origin master

 

7.报错 error:无法推送一些引用到 'https://'

从Linux 上传代码到github

解决方法:

强行上传

git push -u origin +master

而后

git pull origin master
正文完
 
admin
版权声明:本站原创文章,由 admin 2019-09-18发表,共计693字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码