step1 : 在github上建立一个 repository

step2 : clone 到本地

$ git clone https://github.com/ntu-juking/softwaretesting.git

step3 :本地修改文件,添加文件等

$  cd softwaretesting
$ nano README.md ****** // 编辑文件README.md
$ git add README.md ******// 可能不是必须的
$ git commit -m "Charpter 1 Modify" // 本地提交 commit

step4:建立远端(github)仓库的别名, 把本地仓库关联远程仓库

$  git remote add origin_RemoteAlias https://github.com/ntu-juking/softwaretesting.git

step5: 本地仓库某分支push 到远端仓库

$  git push origin_RemoteAlias  master         ***// origin_RemoteAlias  远端仓库别名,任意取, 一般是origin。
***********************// master := 当前分支名**。

step5':远端仓库 pull 到本地仓库

$  git pull +origin(远程名字)+master(远端分支名):branch_local(本地分支,缺省为当前分支)
  • 把远程仓库最新版本放到本地仓库 (如果没有冲突,则正确执行)

同步冲突解决办法

  • 如果上次提交之后,在服务器端、本地端 都分别修改了对应分支下的文件,则会发生冲突
$ git pull origin mindmap

错误信息如下:

From https://github.com/ntu-juking/softwaretesting

* branch mindmap -> FETCH_HEAD

error: Your local changes to the following files would be overwritten by merge:

mindmap/Lec07_Exp_PerformanceTesting.md

Please commit your changes or stash them before you merge.

Aborting

解决办法:

 $ git mergetool ,执行冲突解决(一般是代码行比对,选择执行哪一个修改)
$ git commit -a -m "merge conflict fixing" , 提交修改
$ git push, 合并修改后,提交到远端服务器

实验1: 测试修改多个文件、子路径下文件、提交、push 到远端

  • 我们建立一个分支(mindmap_local,本地分支用于介绍各个讲座的知识要点)
  • 分别用Lec00_name.md, Lec01_name.md, ...... , LecNN_name.md, 为了便于管理,新建一个文件夹(不妨叫mindmap),把这些文件置于文件夹mindmap中
 $  git add   .                    ******************************************************   // 添加到本地库**
$ git commit -m "add mindmaps" *********************************** // 提交变化到本地卡**
$ git push origin(远端库) mindmap(远端分支):mindmap_local(本地分支,可省略) ***********// push 到github库**

git & github 同步文件的更多相关文章

  1. 在windows下安装Git并用GitHub同步

    准备环境: 1,注册github账户 2,下载安装git(下载地址:https://git-scm.com/download/win) 注释: git是什么? git是版本管理工具,当然也是分布式的管 ...

  2. 【Git】本地与GitHub同步

    按步骤一步一步来,成功啦~ 以管理员身份运行Git-bash 要求输入用户名,密码 成功推入github~~加油加油 补充: 将仓库中的改动同步到本地 在git-bash中进入项目目录下,使用git ...

  3. 【Git/GitHub学习笔记】基本操作——创建仓库,本地、远程同步等

    近日想分享一些文件,但是用度盘又太麻烦了(速度也很恶心).所以突发奇想去研究了下GitHub的仓库,这篇文章也就是一个最最最基础的基本操作.基本实现了可以在GitHub上存储文本信息与代码. 由于我的 ...

  4. Git 从github克隆文件至本地

    学习阶段,同一个项目,如何保障家与公司的代码同步的问题,可以使用git克隆来解决 在家将项目提交到了GitHub上,现在来到公司,需要将GitHub上的项目克隆到本地,那么对于公司的电脑来说,同样需要 ...

  5. Git与GitHub同步

    如何通过Git Bash实现本地与远端仓库——GitHub的同步 1.下载安装Git:下载网址 2.在自己的github上新建一个repository 例如我这里新建了一个叫test的reposito ...

  6. git与github建立链接(将本次项目与网络GitHub同步) --转存笔记

    转载自:https://blog.csdn.net/qq_36529459/article/details/79047220 1.(先进入项目文件夹)通过命令 git init 把这个目录变成git可 ...

  7. 使用git将本地文件提交到github存储库

    1.首先你要安装git https://git-for-windows.github.io/ 去官网自行下载对应版本 2.安装好git服务器后,找到你项目的文件夹,右键git bash here打开命 ...

  8. git上传文件到github

     一.git之上传代码到github. 安装git,这个就不说了,很多帖子都有详细说明.  二.新建仓库,GitHub上的,首先申请账号.  三.本地选择地方新建本地仓库. 建完本地仓库文件夹,在本地 ...

  9. 由于github仓库中提前建立readme文件,导致git push报错error: failed to push some refs to 'git@github.com:

    $ git push -u origin master To git@github.com:xxx/xxx.git ! [rejected] master -> master (fetch fi ...

随机推荐

  1. zabbix4.0下zabbix-agentd安装

    转:http://www.safecdn.cn/monitor/2018/12/zabbix4-0-zabbix-agentd-install/316.html 一 安装源和Zabbix的依赖包: 1 ...

  2. BASEDIR

    1)正常写python程序会有一个可执行的bin.py文件,假如这个文件需要导入my_module里面定义的模块,应该怎么设置sys.path(此时可以直接导入), 因为bin和model属于同级目录 ...

  3. Object.create() vs new SomeFunction() in javascript

    Object.create builds an object that inherits directly from the one passed as its first argument. Wit ...

  4. SpringBoot的spring-boot-starter有哪些(官方)

    看完这些,你就知道每个spring-boot-starter依赖些什么东西了. 地址:https://github.com/spring-projects/spring-boot/tree/v2.1. ...

  5. 坑之mysql 字符串与数字操作

    select "123"+1 = 124; select "1a23"+1 = 2; select "aa23"+1 = 1; select ...

  6. 将python、pip 加入环境变量

    加python: CMD里输:    path=%path%;C:\Python27 其中   C:\Python27  为python的exe所在的文件夹 加pip: CMD里输:    path= ...

  7. [Java核心技术]第四章-对象与类(4.1-4.6总结)

    4.1面向对象程序设计概述 OOP(面向对象编程Object Oriented Programming) OOP中数据第一位,算法第二位. 类 封装:关键在于不能让其他方法直接访问类的实例域,程序仅通 ...

  8. project1

    知识漏洞  有空就默写一下-.- [概念] 要好好理解并且背下来记住 MVC要分开,Servlet里面不处理计算的逻辑,只有调用函数(是不是变量传进来以后,调用都不能有呢?) clear map不能直 ...

  9. [leetcode]88. Merge Sorted Array归并有序数组

    Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: T ...

  10. redis 3.2.1 centos7

    设置外网访问 vmare:centos7redis:3.2.1 redis-cli shutdown 重启./redis-server 启动服务 启动之后无法访问 cd redis-3.2.1 vim ...