草 稿

初学上传文件到github

入程序员大坑,教大家如何上传文件到github

  1. 建立仓库,creat respository

    在github首页的右上角,点击红框中的Create New Respository。

  2. 填写相关信息,点击创建

    按照提示填写相关信息。

  3. 克隆仓库

    从github上下载命令行工具。下载地址:http://windows.github.com/

     

    然后进行简单的安装之后,会在桌面上创建两个图标,GitHub和Git Shell,GitHub是图形界面,Git Shell是命令行模式,而且默认的Git仓库是建在C盘的,个人建议要把路径重设下。

     

    点开Git Shell,进入命令行。首先我们先要把GitHub上的我们新建的仓库clone下来,为了演示,我在GitHub上新建了一个名称为iOS-dev-tools的git。

     

    在初始化版本库之前,先要确认认证的公钥是否正确,如下:

    ssh -T git@github.com

    接下对库进行clone,如下:

    git clone https://github.com/Koneey/iOS-dev-tools.git

  4. 上传README.md文件

    这个时候,GitHub文件夹下就多了一个iOS-dev-tools文件夹,进入文件夹目录,对仓库进行初始化。

    命令如下:

      git init

      touch README.md

      git add README.md

      git commit -m 'first_commit'

      git remote add origin https://github.com/koneey/iOS-dev-toolsg.git

      git push origin master

  5. push文件

    创建完README.md后,就可以push了,代码类似。

    代码:

      git add .

      git commit -m 'first_commit'

      git remote add origin https://github.com/koneey/iOS-dev-toolsg.git

      git push origin master

     

    如果执行git remote add origin https://github.com/findingsea/myRepoForBlog.git,出现错误:fatal: remote origin already exists

    则执行以下语句:git remote rm origin

    再往后执行git remote add origin https://github.com/findingsea/myRepoForBlog.git

    在执行git push origin master时,报错:error:failed to push som refs to.......

    则执行以下语句:git pull origin master

    先把远程服务器github上面的文件拉先来,再push 上去。

评论(0