今天在做一项MVC4Demo之后,突发奇想,想把它上传到GitHub,可是之前都在Mac上传项目的,现在转到Windows下来了,又要重新学习怎么上传,学习过后发现并没有太大区别,下面趁热打铁,记录一下上传过程,给有需之人多个参考,好了,废话少说,上教程~
首先:随便找个盘新建一个项目

打开Test文件夹,在里面放置你的项目,这里示范一下,新建一个main.c(请先忽略左边的文件,一会初始化的时候会自动出现)

右键点击Git Bash Here(没有这个选择的话,请点击这里:http://www.jianshu.com/p/c0268827cd38)

打开命令面板后输入:
git init //初始化一个本地仓库

然后,在GitHub上新建一个仓库:



上面这个链接很重要
然后执行命令:
git remote add origin git@github.com:AganYa/Test.git
git push -u origin master
如果输入$ git push origin master
提示出错信息:error:failed to push som refs to .......
解决办法如下:
1、先输入$ git pull origin master //先把远程服务器github上面的文件拉下来
2、再输入$ git push origin master
3、如果出现报错 fatal: Couldn't find remote ref master或者fatal: 'origin' does not appear to be a git repository以及fatal: Could not read from remote repository.
4、则需要重新输入$ git remote add git@github.com:AganYa/Test.git
好了,以上步骤做完后正式上传项目
敲一下命令:
git add . //或者你项目名称,“.”是全部上传
git commit -m "上传信息"

最后需要设置以下个人信息,输入:
git config --global user.name "你的名字" (此处name可随便填写)
git config --global user.email "你的邮箱"
看到以下信息就上传成功了,祝你好运~

最后附上成功上传后的效果以及个人GitHub链接:https://github.com/AganYa(上面是之前学习iOS开发的一些小Demo以及一些学习方法,喜欢的话可以点点Star哟~)

网友评论