发布项目到GitHub

首先根据下图的操作创建一个仓库,这是干什么的?可以简单粗暴的理解为一个项目一个仓库就行了。

创建成功后看到到下图,这图的那个地址先记住了,一会可是要用的呢,这是这个仓库的地址,我们项目要传到这里来。

然后就去下载一个git,可以网上搜索git下载,会有很多教程,这里宝宝贴出官方的下载地址:https://git-scm.com/downloads/    还有一个网上找的安装教程:http://jingyan.baidu.com/article/7f766dafba84f04101e1d0b0.html

接着打开Git的安装路径,打开git-bash.exe,然后会发现打开了一个打命令行的东西。

就是这个东东,我们就是要在这里写命令行。

宝宝的项目放在J:\MVPDemo\MVPDemo ,我们第一步就是要进入这个目录下,cd 是用来进入某个目录的,白色的字是宝宝打的(前面那个美元符号是自动生成的),然后现在就进入了我们要上传路径的目录下。

第二步输入git init,如下图所示,这个意思是在当前项目的目录中生成本地的git管理(会发现在当前目录下多了一个.git文件夹

第三步输入git add .,这个是将项目上所有的文件添加到仓库中的意思,如果想添加某个特定的文件,只需把.换

成这个特定的文件名即可。

第四步输入git commit -m "first commit",表示你对这次提交的注释,双引号里面的内容可以根据个人的需要

改。

如出现如下错误:

* Please tell me who you are. 

Run 

git config –global user.email “[email protected]” 

git config –global user.name “Your Name”

to set your account’s default identity. 

Omit –global to set the identity only in this repository. 

fatal: unable to auto-detect email address

解决办法: 

第一种:打开终端,进入自己的项目下,有个.git目录

cd ~/MyPro/.git 

vi config

[core]

      repositoryformatversion = 0

           filemode = true

           bare = false

           logallrefupdates = true

           ignorecase = true

 #添加以下三行:

[user]

     email = [email protected]

     name = yourname

第二种:

git config --global user.email "你的邮箱"
git config --global user.name "你的名字"

第五步输入git remote add origin https://自己的仓库url地址(上面有说到) 将本地的仓库关联到github上,

这里宝宝输入的是git remote add origin https://github.com/SilasGao/MVPDemo.git

最后一步,输入git push -u origin master,这是把代码上传到github仓库的意思。

如出现如下错误:

error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:hahaha/ftpmanage.git'

git pull -u origin master再git push -u origin master

执行完后,如果没有异常,会等待几秒,然后跳出一个让你输入Username和Password 的窗口,你只要输入

github的登录账号和密码就行了。

   

账号密码都正确的话,会看到下面这么一个东西,进度还会跳,这个是上传过程中的进度,这个过程可能有点慢,有时候得等个10几分钟,这时候去github上面看,还是什么都没有的,所以大兄弟别着急,先做点其他的事,晚点再来看看。

上传成功后,就是这个样子了。

猜你喜欢

转载自blog.csdn.net/L15810356216/article/details/80503387