git 将本地项目上传到github

首先在github上创建你的仓库
这里写图片描述

点击New repository
这里写图片描述
最后选择license的话可以去看看github licence是怎么选择的,这选择GPL2.0

打开终端

mkdir warehouse
cd warehouse
git init

把你的项目移动到warehouse目录下,项目名字为test

git add test
git commit -m "test"
git remote add origin github仓库的ssh地址

报错:

fatal: remote origin already exists.
zhengdeMacBook-Pro:warehouse zheng$ git remote rm prigin
error: Could not remove config section 'remote.prigin'

但是之前我输入
这里写图片描述
说明我在github上是将ssh key配好了的

解决办法是不要用ssh的地址,用https的地址

git remote add origin github仓库的https地址
git push origin master

如果还不行,输入以下命令:

git remote rm origin

(注:但假设确实是你在github上没把ssh key配好,请先把ssh key给配好)

要求你输入github的用户名和密码,就输入、回车
还是报错:

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/zheng/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

因为没有把远程的readme.md文件下下来,用git pull是没用的。

git pull --rebase origin master

然后发现本地多了LICENSE和README.md两个文件
再:

git remote add origin github仓库的https地址
git push origin master

成功!

把github的项目下下来

mkdir myProjet
cd myProject
git clone github仓库的https地址

转载请标明原址:http://blog.csdn.net/zheng911209/article/details/49923653

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值