提交选择更改到另一个分支,然后恢复在当前分支上工作? [英] Commit select changes to another branch then resume work on current branch?

查看:111
本文介绍了提交选择更改到另一个分支,然后恢复在当前分支上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这经常发生在我的工作流程中:我正在一个单独的分支中开发一个功能,并且在做这件事情时,我会遇到需要修复的小问题,但是例如来自框架或站点布局的较高层。

This happens often in my work flow: I'm working on a feature in a separate branch, and while doing this I'll come across small things that need fixing but are from higher up in the framework or site layout for example.

我想切换回主开发分支,并从那里的选择文件提交更改,然后返回到功能分支和rebase,以便我可以继续使用不相关的调整/错误修正。

I want to switch back to the main develop branch and commit changes from select files there, then go back to a feature branch, and rebase so that I can continue there with the unrelated tweaks/bugfixes out of the way.

我使用 git stash git stash pop 来做到这一点,但是我从一堆我修改过的文件中得到了很多冲突,但是没有无论如何都需要向父分支提交。

I'm using git stash and git stash pop to do this, but I'm getting a lot of conflicts from a bunch of files I modifed but don't need to be committed to the parent branch anyway.

是否有另一种避免冲突或以某种方式保存当前状态的方法,并且只将选择工作树更改拖到另一个分支提交? (有点像git-stash-cherry-pick; - ))

Is there another way to avoid conflicts or somehow save the current state, and only pull select working tree changes to another branch for commiting ? (sort of like git-stash-cherry-pick ;-))

推荐答案


  1. 提交更改您需要在您当前分支上的 master 中。

  2. 存储剩余的更改
  3. 切换到 master 分支并使用 git cherry-pick 将更改移动到 master
  4. 移回到您的羽毛分支, rebase (可选)

  5. 取消原始功能变更

  1. Commit the changes that you want in master on your current branch.
  2. Stash your remaining changes
  3. Switch to master branch and use git cherry-pick to move the changes onto master
  4. Move back to your feather branch, and rebase (optional)
  5. Unstash the original feature changes

这篇关于提交选择更改到另一个分支,然后恢复在当前分支上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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