Git - Cherry选择一个提交请求的提交 [英] Git - Cherry pick a single commit for pull request

查看:143
本文介绍了Git - Cherry选择一个提交请求的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可能还没有这个术语。我将文件添加到git上的开放项目中。我分出了这个项目。我做了一些更改,最后一次提交的是我想要向该项目请求的文件,而不是我之前做的小改动。当我去github网站并提出pull请求时,我会在所需的一个文件的最后一个之前得到所有提交,我不想提交所有其他提交,因为我不认为它是必需的该项目。只是我自己的改变。我该怎么办?如果可能的话,我应该再单独制作另一个res或附加文件并提交。

从远程HEAD中,选择提交到该分支,将分支推送到GitHub上的回购,然后创建一个请求。

  git checkout -b mybranch 
git fetch upstream
git reset --hard upstream / master
git cherry-pick< commit-hash>
git push origin mybranch:mybranch


I might not have the terminology down yet. I made file to be added to a open project on git. I forked the project. I made some changes and my last commit is the file I want to request to the project and not the small changes I made before hand. When I go to github site and make pull request I get all the commits before the one I want which is last one of a file and I don't' want to submit all of the other commits because I don't think its necessary for the project. Just my own changes. What do I do? Should I just make another res or attach the file singularly and submit, if that's possible.

解决方案

You need to create a fresh branch from the remote HEAD, cherry-pick the commit to that branch, push the branch to your repo on GitHub, then create a pull request.

git checkout -b mybranch
git fetch upstream
git reset --hard upstream/master
git cherry-pick <commit-hash>
git push origin mybranch:mybranch

这篇关于Git - Cherry选择一个提交请求的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆