拉取请求覆盖较早的提交 [英] Pull requests overriding earlier commits

查看:199
本文介绍了拉取请求覆盖较早的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个Git仓库(在GitHub上),我有很多对Git没有经验的编码人员。当我聘用他们时,我会要求他们向我的存储库发出拉取请求,以便在合并之前审查他们的更改。目前我最大的问题是,我们经常在更改到我的存储库后将它们合并到存储库中,但在他们发出pull请求之前,意味着合并它们的pull请求会覆盖先前的提交。



有没有办法让我确保这不会发生,而不是告诉他们避免这个问题?

解决方案

确保不会发生这种情况的方法是拒绝任何不能以快进方式应用的提交。

但是,没有任何东西阻止用户在不首先更新他/她的情况下提交拉取请求自己的分叉。



正确的拉取请求应该以快进的方式应用,这意味着贡献者应该首先在最新的提交之前重新布置他/她的工作目标repo(即git pull --rebase),之前发出pull请求。



换句话说,他们应该首先整合你的其他你已经在自己的本地回购合并的变化,测试继承人贡献仍然有效,之前请求。

如果他们这样做,覆盖以前的提交不会有任何问题。

If有,你只是拒绝拉请求,要求贡献者首先rebase本地回购。


I am new to Git so bear with me.

I have a Git repository (on GitHub) and I have lots of coders who are inexperienced with Git. When I hire them, I ask them to make a pull request towards my repository so I can review their changes before I merge. At the moment my biggest problem is that often I merge changes into my repository after they fork it, but before they make their pull request, meaning that merging their pull request overrides an earlier commit.

Is there a way for me to ensure that this will not happen apart from telling them to avoid the problem?

解决方案

The way to ensure that this will not happen is to reject any commit which cannot be applied in a fast-forward manner.
But nothing prevent a user to submit a pull-request without first updating his/her own fork.

A correct pull request should be applied in a fast-forward manner, which means a contributor should first rebase his/her work on top of the latest commit of the destination repo (ie git pull --rebase), before making the pull request.

In other words, they should first integrate your other changes you have merged in their own local repo, test that their contribution is still working, before the pull request.
If they do that, there won't be any issue with overriding earlier commits.
If there is, you simply reject the pull request, asking the contributor to rebase the local repo first.

这篇关于拉取请求覆盖较早的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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