Git 如何删除合并分支的更改以获得干净的功能
问题:我们需要一个测试环境,可以使用相同的数据库进行不同的代码更改,而无需让代码支持所有不同的数据库更改。
事情有时会因为代码和数据库不同步而中断(例如:找不到列)
这是我对无法正确描述的问题的解决方案的示例,它最后有自己的问题:
我们有这些分支:
开发
Team_branch
New_Feature_Branch
Main_Test_Environment 使用使用 Main_Database 的开发分支
Team_Test_Environment 使用 Team_Branch,而 Team_Branch 使用 Team_Database
一旦 New_Feature_Branch 完成,它就会添加到 Team_Branch 以在 Team_Test_Environment 上进行测试
假设 New_Feature_Branch 一切正常,可以上线。我们如何在不进行 Team_Branch 的所有更改的情况下将 New_Feature_Branch 纳入 Develop 分支?
如果我们不需要 New_Feature_Branch 中的 Team_Branch 更改来开始处理它,这将很容易:
开发的新功能 ->完成功能 ->合并到Team_Branch ->获得批准->将功能合并到开发中。
完毕。但是,因为我们使用不同的数据库并且需要同步代码和数据库,所以我们需要像这样开始:
Team_Branch 的新功能 ->完成功能 ->合并到Team_Branch ->获得批准->将功能合并到开发中。
坏的和错误的
现在,当我们只需要 New_Feature_Branch 时,我们在 Develop 分支中拥有所有 Team_Branch 更改!
我们如何解决这个问题?
编辑以响应 merge-base 作为解决方案:
我测试了它,但不幸的是它似乎无法完成这项工作。因为:
Feature_1是从合并基础创建的 ->完成的功能->合并到Team_Branch以发布测试。
从合并基础创建的 Feature_2 ->错误!因为 Feature_1 更改了代码和数据库的内容,并且我们没有 Feature_1 提交,但我们使用相同的数据库。
这就是为什么从 Team_Branch 开始是必要的(我认为?)以获得最新的更改,而不必创建新的数据库。
我确实想让 Team_Branch 尽可能与 Develop 保持同步,因此我会经常将 Develop 合并到 Team_Branch 中。
Problem: We need a test environment that can use the same database for different code changes without having to have the code to support all the different database changes.
Things sometimes break because the code and the database are not in sync (ex: can't find column)
Here's an example of my solution to the problem that I can't properly describe, which has its own problem at the end:
We have these branches:
Develop
Team_branch
New_Feature_Branch
Main_Test_Environment uses Develop branch which uses Main_Database
Team_Test_Environment uses Team_Branch which uses Team_Database
Once New_Feature_Branch is finished it is added to Team_Branch to be tested on Team_Test_Environment
Let's say New_Feature_Branch is all good to go live. How do we get New_Feature_Branch into Develop branch without all the changes from Team_Branch?
This would be easy if we didn't need the Team_Branch changes in our New_Feature_Branch to begin working on it:
New Feature from Develop -> Finish Feature -> Merge into Team_Branch -> Was approved -> Merge feature into Develop.
Done. However because we're using a different database and need to have our code and database synced, we NEED to start like this:
New feature from Team_Branch -> Finish Feature -> Merge into Team_Branch -> Was approved -> Merge feature into Develop.
BAD AND WRONG
Now we have all the Team_Branch changes in Develop branch when we only want the New_Feature_Branch!
How do we solve this?
EDIT in response to merge-base as a solution:
I tested it out, but unfortunately it seems like it won't do the job. Because:
Feature_1 created from the merge-base -> finished feature -> merged into Team_Branch to be published for testing.
Feature_2 created from the merge-base -> Error! Because Feature_1 changed stuff on code and database and we don't have Feature_1 commits but we're using the same database.
That's why starting from Team_Branch is necessary (I think?) to have the latest changes and not have to create a new database.
And I do want to keep Team_Branch as up to date with Develop as possible, so I will be merging Develop into Team_Branch often.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论