首先在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