跳到 git diff 中的下一个修改过的文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13464540/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:46:39  来源:igfitidea点击:

Skip to next modified file in git diff?

git

提问by Abe Miessler

I made the mistake of upgrading a Visual Studio project from 2008 to 2010 without checking in my previous changes first. Because of this I have a huge system generated file (10k+ lines) that had every 4th line changed.

我犯了一个错误,将 Visual Studio 项目从 2008 年升级到 2010 年,而没有先检查我以前的更改。因此,我有一个巨大的系统生成文件(10k+ 行),每 4 行更改一次。

I'm usually pretty good about checking in stuff often, so I will typically just use the down key to scroll through my changes. In this case it will take several lifetimes to scroll through the changes to the system generated file.

我通常很擅长经常检查东西,所以我通常只使用向下键来滚动我的更改。在这种情况下,滚动浏览对系统生成文件的更改将需要几个生命周期。

Is there a way to skip to the next modified file after you have done a git diffso that you don't have to scroll through every change on every file?

有没有办法在完成后跳到下一个修改过的文件,git diff这样您就不必滚动浏览每个文件的每个更改?

回答by Greg Hewgill

By default, git diffpipes its output through less. So you can use the lesscommands to search for the next header. Type /^diffand press Enterto skip to the next file.

默认情况下,git diff它的输出通过less. 所以你可以使用less命令来搜索下一个标题。键入/^diff并按Enter跳到下一个文件。

回答by Nikita G.

For other useful commands type hfor help (while being in git diff, which is being in less).

对于其他有用的命令,请键入h帮助(在 中git diff,在 中less)。

In particular:

特别是:

                           JUMPING

  g  <  ESC-<       *  Go to first line in file (or line N).
  G  >  ESC->       *  Go to last line in file (or line N).
  p  %              *  Go to beginning of file (or N percent into file).
  t                 *  Go to the (N-th) next tag.
  T                 *  Go to the (N-th) previous tag.
  {  (  [           *  Find close bracket } ) ].
  }  )  ]           *  Find open bracket { ( [.
  ESC-^F <c1> <c2>  *  Find close bracket <c2>.
  ESC-^B <c1> <c2>  *  Find open bracket <c1>

回答by Smithee

While in git diff, simply hit nto go straight to the next file, and again to the one afterwards, and so on.

在 中git diff,只需点击n即可直接进入下一个文件,然后再次进入下一个文件,依此类推。

You can also use Nto go back a file.

您还可以使用N返回文件。

(For these commands to work, you'll need to first type /^diffand press Enter, as explained in this answer.)

(要使这些命令起作用,您需要先键入/^diff并按Enter,如本答案中所述。)

回答by mgarciaisaia

I'd suggest you to use tig. It's a curses interface for git, and a very good one.

我建议你使用tig. 这是一个用于 的curses 接口git,并且是一个非常好的接口。

With tig statusyou can see the index status, and by pressing Enteron any of the files, you see it's diff. hshows you the help menu, but it's a vi-shortcuts-based interface.

有了tig status你可以看到索引状态,按Enter上的任何文件,你看它的差异。h向您显示帮助菜单,但它是一个基于 vi 快捷方式的界面。

I think in any debian-based distro you can just apt-get installit, or you can make it from the linked site.

我认为在任何基于 debian 的发行版中,您都可以使用apt-get install它,或者您可以从链接站点制作它。

回答by R0MANARMY

Another option is to call update-indexcommand and tell it to pretend that one giant file didn't change. There's a more complete example here.

另一种选择是调用update-indexcommand 并告诉它假装一个巨大的文件没有改变。有一个更完整的例子在这里