简体   繁体   English

Git:在隐藏到当前版本之间手动合并?

[英]Git: Manually merge between stashed to current version?

While working on a feature I stashed my changes at times, when I thought there is a lot things done. 当我从事某项功能时,有时会做很多事情,因此有时会隐瞒更改。

Now I realised I need some code that I implemented, stashed, then removed and stashed again. 现在,我意识到我需要一些实现,隐藏,然后删除并再次隐藏的代码。 So I currently don't have it, but I have it in one of my shashed versions. 所以我目前没有,但是我有一个隐藏版本。

So I can't just apply that stashed version, because there is a lot of things I don't need to be merged. 因此,我不能只应用该隐藏版本,因为有很多东西我不需要合并。 Is there a way to merge it manually? 有没有办法手动合并它?

Basically, I can see git diff between current version and stashed one with: 基本上,我可以看到当前版本之间的git diff并以以下方式隐藏:

git diff stash@{n}

But how can I use a merge tool (I usually use "meld") to merge? 但是,如何使用合并工具(通常使用“合并”)进行合并?

"Meld" is not a must. “强制”不是必须的。

Just do git stash apply (or pop ), and it brings the changes into you working directory. 只需执行git stash apply (或pop ),它将更改引入您的工作目录。 Then you could undo undesired changes and commit. 然后,您可以撤消不需要的更改并提交。

This is fairly simple 这很简单

  • checkout your branch and make sure there are no unchanged files 签出您的分支,并确保没有未更改的文件
  • apply the stash version you need, say n, with "git stash apply stash@{n}" 使用"git stash apply stash@{n}"应用所需的存储版本,例如n
  • now check the changes, keep the ones you need and remove the others; 现在检查更改,保留您需要的更改,然后删除其他更改; Meld should work all right here Meld应该在这里工作
  • once you are sure you have the subset of changes you need, add and commit all the files 确定拥有所需更改的子集后,添加并提交所有文件

PS: Just to clarify, I think you meant to say using Meld as a diff-tool, and not merge tool. PS:只是为了澄清一下,我想您是说要使用Meld作为差异工具,而不是合并工具。 There is no merge happening in the question. 问题中没有merge发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM