简体   繁体   English

Git存储库和Atom IDE:如何有效地将分支的当前版本与旧提交上的新分支进行比较?

[英]Git repository and Atom IDE: how to efficiently compare the current version of a branch with a new one on an old commit?

I have a branch (let's called it "my_fixes") in my repository that has had a number of changes throughout a long period of time. 我的存储库中有一个分支(我们称其为“ my_fixes”),该分支在很长一段时间内进行了许多更改。 Pretty much all files had some significant changes, but now I need to branch off from it and work on a feature I previously worked on a while ago and whose changes are part of a previous commit of my "my_fixes" branch. 几乎所有文件都有一些重大更改,但是现在我需要从中分支出来,并使用我之前使用过的功能,该功能的更改是我的“ my_fixes”分支先前提交的一部分。 I would like to find out what is the most efficient way to compare changes/diff between the two branches in Atom. 我想找出最有效的方法来比较Atom中两个分支之间的更改/差异。 I currently have installed GitDiff and OpenInGit package and use Git both via command line and via GitHub desktop application. 我目前已经安装了GitDiff和OpenInGit软件包,并通过命令行和GitHub桌面应用程序使用了Git。 I would normally revert the newly created branch to the commit of interest, add both the "my_fixes" and the new ones as Atom project and use GitDiff to move through the changes. 通常,我会将新创建的分支还原为感兴趣的提交,将“ my_fixes”和新分支添加为Atom项目,并使用Gi​​tDiff进行更改。 Is that the best way? 那是最好的方法吗? Any recommendation is more than welcome. 任何建议都值得欢迎。

Thanks 谢谢

There are extraordinarily few cases in which you should have a long-running development branch (and for someone that needs to ask this question, I would go as far as to say none). 在极少数情况下,您应该拥有一个长期运行的开发分支(对于需要问这个问题的人,我什至不说什么)。

It sounds like what you're saying is that you have two branches, <old-feature> and <my-fixes> , and changes that you committed in <old-feature> were rebased/cherry-picked or manually applied in <my-fixes> many commits ago, and now you're seeking to figure out how to diff the two branches in such a way that you can easily figure out what changes you need to analyze. 听起来您在说的是您有两个分支,分别是<old-feature><my-fixes> ,并且您在<old-feature>中提交的更改已重新设置/樱桃选择或在<my-fixes>手动应用<my-fixes>以前有很多提交,现在您正在设法弄清楚如何<my-fixes>两个分支,以便可以轻松弄清楚需要分析哪些更改。

The solution I think you're looking for is 我认为您正在寻找的解决方案是

git diff --stat <old-feature> <my-fixes>

which will give you the list of files that have changed, and then 这将为您提供已更改文件的列表,然后

git diff <old-feature> <my-fixes> -- <fileA> <fileB> ... <fileZ>

which will show you the difference between files <fileA> <fileB> ... <fileZ> between <old-feature> and <my-fixes> . 这将显示<old-feature><my-fixes>之间的文件<fileA> <fileB> ... <fileZ>之间的<fileA> <fileB> ... <fileZ>

I'm a big fan of Github if you can use that. 如果可以使用的话,我是Github的忠实拥护者。 Just push it and compare the two branches over it, like in Rails . 像在Rails中一样,只需推动它并比较它上面的两个分支即可。

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

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