创建一个项目========================
- 回到github首页,点击页面右下角“New Repository”
填写项目信息:
project name: hello world
description : my first project
点击“Create Repository” ; 现在完成了一个项目在github上的创建。
- 我们需要使用git在本地创建一个相同的项目。
复制代码
$ makdir ~/hello-world //创建一个项目hello-world
$ cd ~/hello-world //打开这个项目
$ git init //初始化
$ touch README
$ git add README //更新README文件
$ git commit -m 'first commit'//提交更新,并注释信息“first commit”
$ git remote add origin git@github.com:defnngj/hello-world.git //连接远程github项目
$ git push -u origin master //将本地项目更新到github项目上去
复制代码
现在查看github上面的hello world 项目,是不是发现已经将本地中的README文件更新上来了。 :) 恭喜!
————————————关于可能出现的错误———————————-
1.在执行
$ git remote addorigin git@github.com:defnngj/hello-world.git
错误提示:fatal: remote origin already exists.
解决办法:
$ git remote rm origin
然后在执行:$ git remote add origin git@github.com:defnngj/hello-world.git 就不会报错误了
- 在执行
$ git push origin master
错误提示:error:failed to push som refs to…….
解决办法:
$ git pull origin master // 先把远程服务器github上面的文件拉下来,再push 上去。
转载于:http://www.cnblogs.com/fnng/archive/2011/08/25/2153807.html