将一些提交移动到功能分支,但将其他提交留在主分支 [英] Moving some commits to a feature branch but leaving others in the master branch

查看:37
本文介绍了将一些提交移动到功能分支,但将其他提交留在主分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定我是否可以对此做任何事情,保持原样并没有太大的困难.

I am not sure if I can do anything about this and it is not a huge hardship to leave it as it is.

我确实尝试通过遵循其他 SO 主题等的步骤来解决问题,但最终丢失了我所有的帮助修订提交和文件.

I did try to fix things by following steps on other SO topics etc. and ended up loosing all my help revision commits and files.

事情有点乱,我会尽力解释.历史记录在一定程度上是可以的:

Things are a little messy and I will try to explain. The history is OK up to a certain point:

从 resource.h 中删除未使用的资源 ID 值

Removing unused resource ID values from resource.h

你能在日志截图的底部看到吗?

Can you see that towards the bottom of the screenshot of the log?

从那时起,大多数提交都是帮助文件修订:

Since that time, the majority of the commits are help file revisions:

  • 删除帮助主题和多余图片
  • 修改帮助主题和图片
  • 添加新的帮助主题和图片

但它变得复杂了,因为有大量的帮助修订提交,我有一些代码更改提交.例如:

But it gets complicated because with that big chunk of help revision commits I have some code change commits. Eg:

向 CMSATools 添加了 SetLoggingPath.

Added SetLoggingPath to CMSATools.

修改了 CChristianLifeMinistryUtils::FillStudentsListBox 方法.现在它从出版商数据库中读取学生.

Revised CChristianLifeMinistryUtils::FillStudentsListBox method. Now it reads the students from the publishers database.

情节变厚了,对于少数人来说,例如:

The plot thickens, for a small handful of them, eg:

向 CPublishersDatabaseDlg 添加帮助菜单.

Add Help menu to CPublishersDatabaseDlg.

在这些情况下,提交是代码更改和帮助修订更改的组合:

In those cases the commit is a combination of code changes and help revision changes:

添加了 OnHelpHelp 菜单处理程序.

Added OnHelpHelp menu handler.

开始编写 Help/HelpPublisherDatabase.html 帮助主题.

Started writing Help/HelpPublisherDatabase.html help topic.

主要问题:

从 master 分支中的这次提交开始:从 resource.h 中删除未使用的资源 ID 值 我可以创建一个名为:help-revisions 的新功能分支,然后,移动提交从主分支到功能分支?

Beginning at this commit in the master branch: Removing unused resource ID values from resource.h can I make a new feature branch called: help-revisions and then, move the commits from master to the feature branch?

如果可能的话,我假设我们只需要移动纯粹有助于修订的提交.我不确定如何处理混合了帮助更改和代码更改的提交.

If it is possible, I am assuming we would need to move just the commits that are purely help revisions. I am not sure how to handle the commits that are a mixture of help changes and code changes.

因此,理想情况下,我希望将所有帮助修订版拆分为一个功能分支,以便将其合并到 master 并在日志中看起来更好.将代码调整提交单独留在 master 中的适当位置.

So, ideally I am hoping to split out all the help revisions into a feature branch so that it can be merged in to the master and look better in the log. Leaving the code tweak commits alone in the master in an appropriate position.

相关问题是其中一些的原因.但毕竟我不打算在这里讨论.

The related matter is the cause of some of this. But I am not going to discuss that here after all.

如前所述,我只是想知道是否有可能改善我所指出的历史记录.

As mentioned, I am just curious as to know if it is possible to improve the history I have as indicated.

我是一个孤独的开发者,所以不必担心其他人的存储库.

I am a lone developer so do not have to worry about other individuals repositories.

感谢您的帮助和时间.

我已经尝试了 rebase.我将所有要拆分的提交标记为编辑.然后我开始了rebase.我勾选了编辑/拆分并根据需要修改它们,直到完成.

I have given the rebase a go. I marked all the commits I wanted to split as edit. Then I started the rebase. I ticked edit/split and revised them as I needed until it completed.

现在我的日志看起来像这样:

Now my log looks like this:

在下面,它看起来像这样:

Underneath, it looks like this:

那么我如何摆脱那个部分?我必须在创建功能分支和挑选樱桃之前解决这个问题.

So how do I get rid of that section? I have to fix that before I create the feature branch and do the cherry picking.

所以,在顶部,我现在有一组新的所有提交,包括拆分的提交.

So, at the top I now have a new set of all the commits including the split ones.

知道了 - 强制推送了 master 分支.

Got it - did a force push of master branch.

推荐答案

这可以通过混合使用cherry-picking 和rebase 来完成.

This can be accomplished by a mixture of cherry-picking and rebasing.

  1. 在所有受影响的提交之前创建一个新的功能分支.然后选择您想要在该新功能分支上进行的所有提交并选择Cherry-pick commits".之后你有一个分支,其中只有选定的提交.

  1. Create a new feature branch which is before all your commits which are affected. Then select all commits you want to have on that new feature branch and select "Cherry-pick commits". After that you have a branch where only the selected commits are on.

切换回上一个分支,并在新创建的分支的父分支上进行 rebase(您需要启用强制").现在再次标记所有精选的提交并选择跳过并启动变基.现在,这个分支不再包含樱桃采摘的分支.

Switch back to the previous branch and do a rebase on the parent of the newly created branch (you will need to enabled "force"). Now mark all cherry-picked commits again and select skip and start the rebase. Now, this branch does not contain the cherry-picked branches any more.

这篇关于将一些提交移动到功能分支,但将其他提交留在主分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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