[英]Git: overwrite all files in a repository from another commit
I have two branches. 我有两个分支。 One is
develop
for development; 一是
develop
求发展;二是develop
求发展。 the other branch is passed
which will have test-passed commits from develop
. passed
了另一个分支,该分支将具有来自develop
测试通过的提交。
We will open a branch to develop a new feature and merge it back to branch develop
when it's done, and we will test all new merged commits in develop
by CI server. 我们将打开一个分支来开发新功能,并在完成后将其合并回分支
develop
,并且我们将测试CI服务器develop
所有新合并的提交。
When a test passes, we want to merge that commit into branch passed
from develop
and overwrite all files in the repository of old branch passed
. 如果测试通过,我们要合并的是提交到分支
passed
从develop
和覆盖在老枝的存储库中的所有文件passed
。 That means, we want to do overwrite , not merge
, and all files in the commits of the branch passed
should be exactly the same to corresponding commits of the branch develop
. 这就是说,我们要覆盖而不是
merge
,并且passed
的分支的提交中的所有文件应与分支develop
相应提交完全相同。
Branch passed
tracks the test-passed commits and we will release the latest passed commit for beta testing. passed
Branch跟踪了passed
测试的提交,我们将发布最新通过的提交以进行Beta测试。
The question is, how to overwrite a branch but not merge into a branch from the branch develop
? 问题是, 如何从分支
develop
覆盖分支但不合并成分支 ?
BTW, I want to keep two separated branches. 顺便说一句,我想保留两个分开的分支。
It sounds like what you want is to have the passed
branch point to the exact same commit as develop
once the tests have passed. 听起来您想要的是一旦测试通过,就将
passed
分支点指向与develop
完全相同的提交 。
You can do it with git branch --force
: 您可以使用
git branch --force
来做到这一点:
git branch --force passed develop
Here's from the git branch
documentation : 这是来自
git branch
文档 :
-f
-F
--force- 力
Reset <branchname> to <startpoint> if <branchname> exists already.如果<branchname>已经存在,请将<branchname>重置为<startpoint>。 Without -f git branch refuses to change an existing branch.
没有-f,git分支拒绝更改现有分支。
If this is REALLY what you want. 如果这真的是您想要的。 You can delete the
passed
and create it again from develop
, which will result develop
to be the same as passed
. 您可以删除
passed
和重新创建develop
,这将导致develop
是一样passed
。 But are you sure you want to do this? 但是您确定要这样做吗? If yes, why don't you just add a tag to that commit in
develop
? 如果是的话,你为什么不只需添加一个标签犯下的
develop
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.