当前位置:首页 > 笔记 > 正文内容

关于初学者上传文件到github的方法

jsc9年前 (2016-09-19)笔记3080

第一步建立先仓库

  第一步的话看一般的提示就知道了,在github新建一个repository(谷歌可以解决),都是可视化的界面操作,所以难度不大。或者看这里:https://help.github.com/articles/create-a-repo 这是官方help,虽然是英文的,但是基本都是图和代码,所以很容易读懂。

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

1.png

进入新建仓库的界面

2.png

填一下仓库名称,Initialize this repository with a README是可选的,不过本人建议最好选上,可以在后面省一个步骤。填好之后,点Create repository就行了。

  【第二步】克隆仓库

  第二步开始就基本进入命令行模式了,不过要先从github上下载命令行工具。下载地址:http://windows.github.com/ 

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

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

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

Markup
  ssh -T git@github.com

正确地结果如下: 

Markup
    Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
  Hi findingsea! You've successfully authenticated, but GitHub does not provide shell access.

会有一个Warning,不用理会。

  接下对库进行clone,如下:

Markup
git clone https://github.com/findingsea/myRepoForBlog.git

上面的地址可以在如下界面找到:


clone成功如下:

Markup
    Cloning into 'myRepoForBlog'...
  Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
  remote: Counting objects: 3, done.
  remote: Total 3 (delta 0), reused 0 (delta 0)
  Receiving objects: 100% (3/3), done.

【第三步】上传README.md文件

  这个时候,我们的GitHub文件夹下就多了一个myRepoForBlog文件夹,进入文件夹目录,对仓库进行初始化,如果我们之前没有勾选创建README,则要先创建README.md文件,不然上传文件会报错。如果在第一步就勾选过了11.png,则可以直接进入第四步

Markup
  git init
  touch README.md
  git add README.md
  git commit -m 'first_commit'
  git remote add origin https://github.com/findingsea/myRepoForBlog.git
  git push origin master

【第四步】push文件

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

Markup
    git add .
  git commit -m 'first_commit'
  git remote add origin https://github.com/findingsea/myRepoForBlog.git
  git push origin master

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

Markup
    fatal: remote origin already exists

则执行以下语句:

Markup
    git remote rm origin

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

  在执行git push origin master时,报错:

Markup
    error:failed to push som refs to.......

则执行以下语句:

Markup
    git pull origin master

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

扫描二维码推送至手机访问。

版权声明:本文由微小站发布,如需转载请注明出处。

本文链接:https://jsc0.com/post/128.html

“关于初学者上传文件到github的方法” 的相关文章

百度坐标和GPS坐标转换

百度地图API中,有GPS坐标转百度坐标的功能http://dev.baidu.com/wiki/static/map/API/examples/?v=1.2&0_6#0&6http接口是:http://api.map.baidu.com/ag/coord/convert?from=...

百度地图被外部调用的问题

选择手机里安装的外部地图应用,在外部地图应用里显示商户的位置。Uri mUri = Uri.parse("geo:39.922840,116.3543240?q=39.922840,116.3543240(北京市西城区阜外大街2号万通大厦)");Intent mIntent =...

equals和==区别

对于==,如果作用于基本数据类型的变量,则直接比较其存储的 “值”是否相等;    如果作用于引用类型的变量,则比较的是所指向的对象的地址对于equals方法,注意:equals方法不能作用于基本数据类型的变量    如果没有对equals方法进行重写,则比较的是引用类型的变量所指向的对象的地址; ...

viewpager、listview、gridview、scrollview去除蓝色阴影

xml:   android:overScrollMode="never"java:    view.setOverScrollMode(ScrollView.OVER_SCROLL_NEVER);...

TabLayout getCustomView为空的问题

今天用Tablayout——ViewPage出现getCustomView为空的问题通过源码发现,ViewPage的adapter更新会吧TabLayout  的customViewc置空。这个时候自动调用OnTabSelectedListener的onTabSelected方法去获取Cu...

Notification 8.0 关闭声音震动

NotificationChannel notificationChannel = new NotificationChannel                    (NOTIFICATION_C...