简体   繁体   English

Git:从另一个提交覆盖存储库中的所有文件

[英]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 . 如果测试通过,我们要合并的是提交到分支passeddevelop和覆盖在老枝的存储库中的所有文件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.

相关问题 如何将 git 存储库(包括所有分支)覆盖到另一个 git 存储库 - How to overwrite a git repository(including all branches) to another git repository 将来自同一项目但完全独立的提交历史记录从一个git存储库合并到另一个 - Merge files from same project but completely independent commit history from one git repository into another 如何从Git存储库中提取对文件夹/归档的所有提交的所有文件? - How to extract all files of any commit to a folder/archive from a Git Repository? 将存储库从一个 git 实例连同所有提交和分支历史记录一起移动到另一个实例 - Moving repository from one git instance to another along with all commit and branch histories Git:覆盖或擦除存储库中的大文件(归档)? - Git: overwrite or wipe large files (archives) from repository? 如何列出添加到GIT存储库第一次提交的所有文件? - How to list all files added to the first commit of a GIT repository? 选定文件上的git存储库提交 - git repository on selected files commit Git从精确提交中检出所有文件 - Git checkout all files from exact commit Git提交所有文件 - Git commit all files GIt:使用BFG从存储库中删除了几个文件,并且提交差异很大 - GIt: Removed several files from repository with BFG and there are enormous commit diffs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM