我可以交互式地从另一个git commit中选择hunk吗? [英] Can I interactively pick hunks from another git commit?

查看:119
本文介绍了我可以交互式地从另一个git commit中选择hunk吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找与

  git add -i -p 

但是我不想从我的工作目录中撰写提交,我想从一个提交的(部分)组成我的工作目录。我怎么做?



我的用例是我有几个不同的功能在一次提交中分组在一起,我想逐个测试它们

使用 cherry-pick -n 并不是很令人满意,因为它让我无法彻底清除所有不需要的代码。我真的只想挑选我想测试的选定变更。 使用樱桃-pick -n并不是真的令人满意,因为它让我不再需要
的肮脏工作,去掉所有不需要的代码。我真的只想选择我想要的
测试所选择的更改。

这项工作可能已经很脏之前,但随着 git checkout --patch ,您现在可以选择性地放弃更改,类似于 git add -p 添加。

I'm looking for exactly the same behavior as

git add -i -p

But instead of composing a commit from my working directory, I'd like to compose my working directory from (parts of) a commit. How can I do that ?

My use case is that I have several distinct features that are grouped together in a single commit and I'd like to test them one by one

Using cherry-pick -n is not really satisfactory, since it leaves me with the dirty job of removing all the unrequired code. I'd really just like to pick the selected changes I want to test.

解决方案

Using cherry-pick -n is not really satisfactory, since it leaves me with the dirty job of removing all the unrequired code. I'd really just like to pick the selected changes I want to test.

The job may have been a dirty one before, but with the advent of git checkout --patch, you can now selectively discard changes, similar to git add -p for adding.

这篇关于我可以交互式地从另一个git commit中选择hunk吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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