text为特定提交做出git拉取请求(代码片段)

author author     2022-11-30     107

关键词:

http://blog.asquareb.com/blog/2014/06/19/making-a-git-pull-request-for-specific-commits/

Making a Git Pull Request for Specific Commits

Time to time when working on a project using a fork from a git repository, situations arise that a pull request need to be made to the master repository for a sub set of commits you made to the fork. The following are a set of steps which can help with accomplishing these scenarios.

On the git repository in your local machine created from your fork, create a new branch
1
git branch cherry-branch origin/master
The assumption is that there is only one branch in your fork and the master repository and origin is pointing to your github fork.

Switch to the new branch created

1
git checkout cherry-branch
You can verify that you are on the correct branch by running the command
1
git branch
Identify ids of the commits you want to include into the pull request from your github fork.

Issue a git cherry-pick command to include the commits into the new branch

1
git cherry-pick COMMIT-ID
Push the new branch to your fork
1
git push origin cherry-branch
On github you can now see the new branch in your fork with only the commits selected. Now a pull request to the master repository.
What if there are multiple branches on the master repository and your fork and you want to send a pull request from a particular branch of your fork to a branch in the master repository.

Create a clone of the master repository branch you are interested in
1
git clone https://github.com/master-owner/project-repo -b interested-branch
Create a remote reference to the local repository of the your fork where all the commits are
1
git remote add -t local-branch-name mylocalrepo /location/of/local/gitrepo
Do a fetch of all the changes available in the local repository from your fork
1
git fetch mylocalrepo
Identify ids of all the commits you want to include into the pull request from your github fork.

Issue a git cherry-pick command to include the commits you want to get pulled

1
git cherry-pick COMMIT-ID
Create a branch
1
git branch cherry-branch
Switch to the new branch
1
git checkout cherry-branch
Push the changes into your fork in github
1
git push https://github.com/yourid/project-repo cherry-branch
Now the branch “cherry-branch” will be show up in github UI with the changes selected. A new pull request can be created for the changes to be committed into the master repository.

Once the changes are merged, the branch can be deleted and the local repository created can be removed.

1
git push origin :cherry-branch

git代码提交规范(代码片段)

...2.GitHooks如同其他许多的版本控制系统一样,Git也具有在特定事件发生之前或之后执行特定脚本代码功能(从概念上类比,就与监听事件、触发器之类的东西类似),GitHooks就是那些在Git执行特定事件(如commit、push、receive等)后... 查看详情

git基础教程(22)绑定上游分支,拉取特定分支代码(代码片段)

gitclone了一个空的远程仓库之后,git默认就给我们创建了一个本地分支叫master:小静静@DESKTOP-MD21325MINGW64/d/11/ggg$gitclonegit@gitee.com:hongjiaheng/test_1.gitCloninginto\'test_1\'...warning:Youappeartohaveclonedanemptyrepository.小静静 查看详情

svn向git进行转换如何拉取指定版本后的提交(代码片段)

...net/p/docutils/code/trunkdocutils-r8000:HEAD可以拉取8000版本以后的提交记录。 对于一些项目老的提交版本过多的话,使用这个命令可以将以前老的提交全部都忽略掉。 查看详情

git提交和获取代码(代码片段)

...取代码gitclonehttps://gitee.com/shllong/Hig/然后创建项目.netcore提交项目的时候需要关闭vs提交项目流程gitinit#创建仓库,如果是从远程获取到的就不需要创建仓库了gitadd.#将当前文件夹添加到仓库中gitcommit-m"描述"#提交仓库到中间库中,... 查看详情

text在laravel中请求特定变量(代码片段)

查看详情

text删除意外提交给git的大文件(代码片段)

查看详情

git基本操作(代码片段)

...码合并到你自己的分支gitpushorignyou_dev开始新的模块开发##提交你的修改gitaddyou_code//你的模块文件信息gitcommit-m"修改或添加了那些东西备注"gitpushoriginyou_dev//提交到你自己的分支分支操作有时间如果想开发一个测试功能的... 查看详情

macos使用git从gitlab拉取代码提交和推送(代码片段)

macOS使用git从gitlab拉取代码、提交和推送1、安装git2、配置全局用户信息3、生成公钥4、gitlab绑定公钥5、从gitlab拉取代码6、提交代码到gitlab6.1个人项目6.2团队项目(上传到指定项目的指定分支)6.2.1新建文件夹6.2.2Git初始... 查看详情

markdown显示在特定git提交中更改的文件(代码片段)

查看详情

markdown显示在特定git提交中更改的文件(代码片段)

查看详情

拉取git代码仓库项目到本地(代码片段)

...新建README文件touchREADME.md7.添加刚创建的文件gitaddREADME.md8.提交addREADME.mdgitcommit-m"addREADME"9.拉取项目gitpush-uoriginmaster 查看详情

如何在拉取请求中压缩提交

】如何在拉取请求中压缩提交【英文标题】:HowtosquashcommitsinaPullrequest【发布时间】:2021-05-1108:03:20【问题描述】:我有一个关于开源存储库的拉取请求,其中包含一个提交,例如commita。现在有人要求我更改该提交中的一些代码... 查看详情

将我所有的提交压缩为一个用于 GitHub 拉取请求 [重复]

】将我所有的提交压缩为一个用于GitHub拉取请求[重复]【英文标题】:SquashallmycommitsintooneforGitHubpullrequest[duplicate]【发布时间】:2013-01-1003:50:33【问题描述】:我在GitHub上提出了拉取请求。现在存储库的所有者说要将所有提交压... 查看详情

mmdet提交pr的学习笔记(代码片段)

官方文档关于如何向MMDet提交PR,请参考mmcv的文档《拉取请求—mmcv1.6.1文档》1.Fork最新代码库当第一次提PR时,需要复刻OpenMMLab代码库,点击GitHub页面右上角的Fork按钮即可将复刻的代码库克隆到本地gitclonefork_mmdetection_... 查看详情

git简单介绍两种拉取代码的方式(代码片段)

.../查看本地git库的文件修改状态gitstatus//将本地修改的代码提交到暂存区./也可以换成具体的文件名gitadd. 查看详情

获取特定用户的问题和拉取请求

】获取特定用户的问题和拉取请求【英文标题】:GettingIssuesandPullRequestsforaspecificuser【发布时间】:2018-03-1818:23:04【问题描述】:我正在根据用户传入的存储库的名称通过API为多个组织拥有的存储库提取所有问题和拉取请求。我... 查看详情

完全恢复拉取请求

...分支也在同时工作。contract被错误地合并到master中。100次提交,日期与已存在的master提交重叠。如何完全删除将所有100个提交从contract合并到master的拉取请求?我们对拉取请求进行了Git 查看详情

git提交代码到自己仓库(代码片段)

经常用到git提交代码记录一下经常用到的几个常规操作如果是别人的仓库先fork到自己仓库如果是自己仓库直接拉取gitclonehttps://仓库地址//xxx.git关联自己账号和邮箱gitconfiguser.name"xxx"gitconfiguser.email"xxx@xxx.com"关联本... 查看详情