Github教程(3)
Pull Request
Pull Request 是自己修改源代码后,请求对方仓库采纳该修改时采取的一种行为。
场景1:
用户A在fork完用户B的项目时,A修改了代码并提交了一个Pull Request给B用户,B用户Merge了A用户提交的Pull Request。
假设需要fork以下项目:
https://github.com/grey927/TestForkPR
点击账户右上角的fork按钮,fork项目到自己账户下


打开Git Bash
将项目clone到本地:
$ git clone https://github.com/GreyZeng/TestForkPR.git Cloning into 'TestForkPR'... remote: Counting objects: , done. remote: Total (delta ), reused (delta ), pack-reused Unpacking objects: % (/), done. Checking connectivity... done.
进入TestForkPR目录,查看分支状态:
$ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master
在TestForkPR目录下增加一个文件,T.java
增加到暂存区:
$ git add T.java
提交修改:
$ git commit -m "this is test" [master 2b72d0f] this is test file changed, insertions(+) create mode T.java
Push到自己账户下的远程仓库下:
$ git push -u origin master Counting objects: , done. Delta compression using up to threads. Compressing objects: % (/), done. Writing objects: % (/), bytes | bytes/s, done. Total (delta ), reused (delta ) To https://github.com/GreyZeng/TestForkPR.git daaf13f..2b72d0f master -> master Branch master set up to track remote branch master from origin.
打开自己账户的远程仓库,点击New Pull Request按钮:

弹出文件差异对比界面

确认无误时,点击Create pull request

写上相关描述并点击Create pull request:

此时,原仓库会收到一条pull request的信息:


点击进入这条信息,

点击Merge pull request,即可接受这个pull request的请求。

场景2:
直接clone原仓库到本地,不执行fork操作,并同时使用fetch/merge命令使本地仓库和原仓库保持代码一致。
举例:
原仓库的地址:https://github.com/grey927/TestFetchMerge
直接clone至本地:
$ git clone https://github.com/grey927/TestFetchMerge.git Cloning into 'TestFetchMerge'... remote: Counting objects: , done. remote: Total (delta ), reused (delta ), pack-reused Unpacking objects: % (/), done. Checking connectivity... done.
给原仓库设置upstream的名称,将其作为远程仓库。
$ git remote add upstream https://github.com/grey927/TestFetchMerge.git
我们每次只要从原仓库获取最新源码,并和本地分支进行合并即可:
获取最新源码:
$ git fetch upstream remote: Counting objects: , done. remote: Compressing objects: % (/), done. remote: Total (delta ), reused (delta ), pack-reused Unpacking objects: % (/), done. From https://github.com/grey927/TestFetchMerge * [new branch] master -> upstream/master
合并:
$ git merge upstream/master Updating e2215cc..a215a8a Fast-forward newfile.txt | + file changed, insertion(+) create mode newfile.txt
Github教程(3)的更多相关文章
- 上传本地代码及更新代码到GitHub教程
上传本地代码及更新代码到GitHub教程 上传本地代码 第一步:去github上创建自己的Repository,创建页面如下图所示: 红框为新建的仓库的https地址 第二步: echo " ...
- 一篇文章了解Github和Git教程-AndroidStudio上传Github教程
前言 为了方便保存自己的代码,下班后可以回家继续进行,自己的码农工作,介绍一下Github. 什么是Github呢? 作为一个编程人员,我觉得得了解一下Github吧! 当然,如果你放弃了码农或者技术 ...
- git 入门教程之github 教程
github 教程 github 是一个基于 git 的代码托管平台,是平时工作学习的好帮手,学会如何用好 github 网站能够帮助我们更好分享代码或者与其他开发人员合作. 注册 github 账号 ...
- 史上最简单的 GitHub 教程
史上最简单的 GitHub 教程 温馨提示:本系列博文已经同步到 GitHub,如有需要的话,欢迎大家到「github-tutorial」进行Star和Fork操作! 1 简介 GitHub 是一个面 ...
- GitHub教程(二) 删除已有仓库
通过GitHub教程(一)的阅读,我相信您对GitHub体系框架已经有了模模糊糊的了解.本节教程将继续介绍GitHub的操作---删除仓库. 作为GitHub的入门使用者,我们可能会建一些简单的仓库来 ...
- GitHub教程(三) 本地仓库托管到GitHub
本文开头先特别声明一下:由于GitHub教程属于Git系列教程的GitHub子篇章,因此GitHub教程中将不再详细介绍Git操作命令及其用法,我会根据实际需要穿插着回顾Git操作命令.如果读者需要学 ...
- GitHub教程--上传项目四步法 GitBash命令行下使用方法
之前就用过GitHub,感觉用GitHub托管自己的代码非常不错.可是之前用的都是窗口化的TortoiseGit,省了很多命令行的操作,但是个人非常喜欢使用命令行,于是,今天就试着用了用GitBash ...
- 【Github教程】史上最全github用法:github入门到精通
原文 http://www.eoeandroid.com/thread-274556-1-1.html [初识Github] 首先让我们大家一起喊一句"Hello Github". ...
- get最简单直接粗爆git与github教程
Git是分布式版本控制系统(可以理解为文件管理拓展工具) github一个在线文件托管系统(可以理解为一个在线云盘) 准备工作,在git官网下载git软件件,安装git软件,以windows.为例,下 ...
- 【Github教程】:github入门到精通
[初识Github] 首先让我们大家一起喊一句"Hello Github".YEAH!就是这样. 原文 http://www.eoeandroid.com/thread-27455 ...
随机推荐
- arcgis手动启动服务提示端口4000被使用
具体解决办法 参考 http://hi.baidu.com/xjx19860908/item/6b46376d92044694c4d249f6该博文. 手动启动,提示4000端口被占用,去查找4000 ...
- Markdown学习语法的记录
标题示例 === 标题示例 ---- #标题示例 ##标题示例 ###标题示例 >引用示例 >>引用示例 >>> 引用示例 _斜体示例_ *斜体示例* __粗体示例 ...
- .NET错误The 'targetFramework' attribute in the <compilation> element of the Web.config file is used only to target version 4.0 and later of the .NET Framework
错误描述: The 'targetFramework' attribute in the <compilation> element of the Web.config file is u ...
- android 自定义日历控件
日历控件View: /** * 日历控件 功能:获得点选的日期区间 * */ public class CalendarView extends View implements View.OnTouc ...
- 记一次苦逼的SQL查询优化
最近在维护公司项目时,需要加载某页面,总共加载也就4000多条数据,竟然需要35秒钟,要是数据增长到40000条,我估计好几分钟都搞不定.卧槽,要我是用户的话估计受不了,趁闲着没事,就想把它优化一下, ...
- [js] js判断浏览器(转)
(function($, window, document,undefined){ if(!window.browser){ var userAgent = navigator.userAgent.t ...
- FoLlow 的技术博客
酷壳 http://coolshell.cn 老赵点滴- 追求编程之美 http://blog.zhaojie.me/ Pixel-In-Gene Blog
- Lua截取utf-8编码的中英文混合字符串
参考博客:UTF8字符串在lua的截取和字数统计[转载] 需求 按字面个数来截取子字符串 函数(字符串, 开始位置, 截取长度) utf8sub(,) = 好1世界哈 utf8sub(,) = 你好1 ...
- SASS用法指南-转
作者: 阮一峰 日期: 2012年6月19日 原文地址:http://www.ruanyifeng.com/blog/2012/06/sass.html 艹,没想到sass 2012年就有了.现在 ...
- assets中放入中文文件名导致Android Studio编译错误
一个android项目突然出现编译错误,如下: :app:processDebugResources FAILED FAILURE: Build failed with an exception. * ...