1. git remote -v
  2. git remote add 别名 地址
  3. git fetch 别名
  4. git merge  别名/分支

第一步:命令行进入到本地.git 所在的目录,查看remote 信息 ,只有 fork

>git remote -v
origin https://github.com/gcontini/xades4j.git (fetch)
origin https://github.com/gcontini/xades4j.git (push)

第二步:添加一个remote ,别名是 upstream ,地址是源项目地址

>git remote add upstream https://github.com/luisgoncalves/xades4j.git

执行完毕之后 \.git\config 文件中增加了三行

[remote "upstream"]
url = https://github.com/luisgoncalves/xades4j.git
fetch = +refs/heads/*:refs/remotes/upstream/*

第三步:查看remote 信息 ,有两个,一个是origin(本地项目从哪来的),另一个是upstream(最原始的项目)

>git remote -v
origin https://github.com/gcontini/xades4j.git (fetch)
origin https://github.com/gcontini/xades4j.git (push)
upstream https://github.com/luisgoncalves/xades4j.git (fetch)
upstream https://github.com/luisgoncalves/xades4j.git (push)

第四步:获取原项目的信息

>git fetch upstream
remote: Counting objects: , done.
remote: Total (delta ), reused (delta ), pack-reused
Unpacking objects: % (/), done.
From https://github.com/luisgoncalves/xades4j
* [new branch] gh-pages -> upstream/gh-pages
* [new branch] master -> upstream/master

执行完毕之后 \.git\refs\remotes\ 文件夹下增加了 upstream 文件夹,其中包含两个分支文件

└─upstream
gh-pages
master

第五步:合并分支(合并remotes\upstream\master 文件中的内容到本地)

>git merge upstream/master
Auto-merging src/test/java/xades4j/verification/XadesVerifierImplTest.java
CONFLICT (content): Merge conflict in src/test/java/xades4j/verification/XadesVerifierImplTest.java
Automatic merge failed; fix conflicts and then commit the result.

第六步: 处理冲突文件

第七步: push到 fork

备注:

查看帮助信息

-h 简要帮助信息

--help 通过浏览器打开文档,显示详细信息

>git remote -h
usage: git remote [-v | --verbose]
or: git remote add [-t <branch>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <name> <url>
or: git remote rename <old> <new>
or: git remote remove <name>
or: git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
or: git remote [-v | --verbose] show [-n] <name>
or: git remote prune [-n | --dry-run] <name>
or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
or: git remote set-branches [--add] <name> <branch>...
or: git remote get-url [--push] [--all] <name>
or: git remote set-url [--push] <name> <newurl> [<oldurl>]
or: git remote set-url --add <name> <newurl>
or: git remote set-url --delete <name> <url> -v, --verbose be verbose; must be placed before a subcommand

remote -h

>git fetch -h
usage: git fetch [<options>] [<repository> [<refspec>...]]
or: git fetch [<options>] <group>
or: git fetch --multiple [<options>] [(<repository> | <group>)...]
or: git fetch --all [<options>] -v, --verbose be more verbose
-q, --quiet be more quiet
--all fetch from all remotes
-a, --append append to .git/FETCH_HEAD instead of overwriting
--upload-pack <path> path to upload pack on remote end
-f, --force force overwrite of local branch
-m, --multiple fetch from multiple remotes
-t, --tags fetch all tags and associated objects
-n do not fetch all tags (--no-tags)
-j, --jobs <n> number of submodules fetched in parallel
-p, --prune prune remote-tracking branches no longer on remote
--recurse-submodules[=<on-demand>]
control recursive fetching of submodules
--dry-run dry run
-k, --keep keep downloaded pack
-u, --update-head-ok allow updating of HEAD ref
--progress force progress reporting
--depth <depth> deepen history of shallow clone
--shallow-since <time>
deepen history of shallow repository based on time
--shallow-exclude <revision>
deepen history of shallow clone, excluding rev
--deepen <n> deepen history of shallow clone
--unshallow convert to a complete repository
--update-shallow accept refs that update .git/shallow
--refmap <refmap> specify fetch refmap
-4, --ipv4 use IPv4 addresses only
-6, --ipv6 use IPv6 addresses only

fetch -h

源项目 -> fork -> 本地 (如何把源项目的代码合并到本地然后推送给fork)的更多相关文章

  1. 如何在IDEA里给大数据项目导入该项目的相关源码(博主推荐)(类似eclipse里同一个workspace下单个子项目存在)(图文详解)

    不多说,直接上干货! 如果在一个界面里,可以是单个项目 注意:本文是以gradle项目的方式来做的! 如何在IDEA里正确导入从Github上下载的Gradle项目(含相关源码)(博主推荐)(图文详解 ...

  2. Spring3 + Spring MVC+ Mybatis 3+Mysql 项目整合(注解及源码)

    Spring3 + Spring MVC+ Mybatis 3+Mysql 项目整合(注解及源码) 备注: 之前在Spring3 + Spring MVC+ Mybatis 3+Mysql 项目整合中 ...

  3. idea中编译项目报错 java: javacTask: 源版本 1.8 需要目标版本 1.8

    问题如上面所叙: > idea中编译项目报错 java: javacTask: 源版本 1.8 需要目标版本 1.8 解决方案: > Setting->Compiler->Ja ...

  4. Visual Studio 2015开发Qt项目实战经验分享(附项目示例源码)

    Visual Studio 2015开发Qt项目实战经验分享(附项目示例源码)    转 https://blog.csdn.net/lhl1124281072/article/details/800 ...

  5. 编译最新版webrtc源码和编译好的整个项目10多个G【分享】

    编译最新版webrtc源码和编译好的整个项目10多个G[分享] 参考https://webrtc.org/native-code/development/编译最新版webrtc源码: Git clon ...

  6. 使用 IDEA 创建 SpringBoot 项目(详细介绍)+ 源码案例实现

    使用 IDEA 创建 SpringBoot 项目 一.SpringBoot 案例实现源码 二.SpringBoot 相关配置 1. 快速创建 SpringBoot 项目 1.1 新建项目 1.2 填写 ...

  7. 在使用 Fortify进行源码扫描时需要做对项目需要做什么?

    1.一般我们的项目都是svn 或git 进行管理的,为了扫出异常的问题 做好把   “” .svn    “”  文件删除 2.把我们的项目需要的jar 文件放到一个文件夹内同项目一起进行扫描.这样为 ...

  8. gitlab或github下fork后如何同步源的新更新内容?

    两种方式: 项目 fetch 到本地,通过命令行的方式 merge 懒人方法,只用 Github ,不用命令行 1.项目 fetch 到本地,通过命令行的方式 merge 提示:跟上游仓库同步代码之前 ...

  9. Spring5源码解析-前奏:本地构建Spring5源码

    构建环境 macOS 10.13.6 JDK1.8 IntelliJ IDEA 2018.3.6 (Ultimate Edition) Spring v5.1.9.RELEASE Gradle 5.5 ...

随机推荐

  1. idea工程中web.xml报错Servlet should have a mapping

    搭建ssm工程过程中web.xml报错:Servlet should have a mapping ....但是mapping已经配置好了...如下图: 搜索无果,后来发现是工程的web.xml位置配 ...

  2. go语言使用go-sciter创建桌面应用(七) view对象常用方法,文件选择,窗口弹出,请求

    view对象的详细文档请看: https://sciter.com/docs/content/sciter/View.htm demo9.html代码如下: <!DOCTYPE html> ...

  3. centos7下的glusterfs的安装与使用

    环境说明: 两台虚拟主机,IP分别为192.168.1.222和192.168.1.233,分别装上glusterfs. 一.下载glusterfs源码包 https://download.glust ...

  4. git常用命令二

    http://www.jianshu.com/p/08c3f1804b36http://backlogtool.com/git-guide/cn/stepup/stepup1_1.html   git ...

  5. EmguCV Image类中的函数(二)使用MorphologyEx进行更多的变换

    MorphologyEx中所有的变换如下图所示 调用方法: Mat aaa = CvInvoke.GetStructuringElement(Emgu.CV.CvEnum.ElementShape.R ...

  6. Vim完全教程

    一.简介 世界上只有三种编辑器,EMACS.VIM和其它.   我们所处的时代是非常幸运的,有越来越多的编辑器,相对于古老的VIM和EMACS,它们被称为现代编辑器.我们来看看这两个古董有多大年纪了: ...

  7. hdu 1257 && hdu 1789(简单DP或贪心)

    第一题;http://acm.hdu.edu.cn/showproblem.php?pid=1257 贪心与dp傻傻分不清楚,把每一个系统的最小值存起来比较 #include<cstdio> ...

  8. VFIO简介 (转载)

    VFIO简介 LTCChina | Nov 20 2013 | Comment (1) | Visits (15204) 概述 VFIO是一套用户态驱动框架,它提供两种基本服务: 向用户态提供访问硬件 ...

  9. YII配置mysql读写分离

    Mysql 读写分离 YIi 配置 <?php return [ 'class' => 'yii\db\Connection', 'masterConfig' => [ // 'ds ...

  10. android 使用UDP发送数据 DatagramSocket 创建对象为null

    DatagramSocket socket=null; try { socket = new DatagramSocket();  //这里创建对象为空 } catch (SocketExceptio ...