多种上传方式
一、使用HTTPS方式上传本地的文件到Github:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| git init
mkdir 文件名 / touch 文档名
git clone https://github.com/user/仓库名.git
git add .
git commit –m '对文件/提交的说明 '
git push -u origin master
|
二、使用SSH方式上传本地的文件到Github:
(1)查看/配置密钥
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| cat ~/.ssh/id_rsa.pub
ssh-keygen -t rsa -C "XXXXX@qq.com"
|
(2)上传到Github仓库
1 2 3 4 5 6 7 8 9 10 11 12
| git init
mkdir 文件名 / touch 文档名
git remote add origin git@github.com:defnngj/hello-world.git
git add 文件
git commit –m '对文件/提交的说明'
git push -u origin master
|
(3) 如果你的HTTPS方法需要每次输入密码,那么可以转成SSH传输
1 2 3 4 5 6 7 8 9 10 11
|
git remote -v origin https://github.com/someaccount/someproject.git (fetch) origin https://github.com/someaccount/someproject.git (push)
git remote set-url origin git@github.com:someaccount/someproject.git
|
git上传过程中出现的错误和方法
(1)Github是不传输大文件的==> 否则报错error:failedto push som refs to …
git push 时,存在大文件会报错,即使删除大文件后,还会报错。主要是因为大文件存在没有被提交的commit记录里面。
(2)[Git撤销&回滚操作(git reset 和 get revert)
1 2 3 4 5 6 7 8
| git pullorigin master git pushorigin master
git remote add origin git@github.com:defnngj/hello-world.git
|
一张图解决Git操作

如有错误,敬请及时指正~