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.
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 diff
so that you don't have to scroll through every change on every file?
In most cases, Git picks A and B in such a way that you can think of A/- as "old" content and B/+ as "new" content. Let's look at our example: Change #1 contains two lines prepended with a "+". Since no counterpart in A existed for these lines (no lines with "-"), this means that these lines were added.
Comparing changes with git diff Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.
By default, git diff
pipes its output through less
. So you can use the less
commands to search for the next header. Type /^diff
and press Enter to skip to the next file.
While in git diff
, simply hit n to go straight to the next file, and again to the one afterwards, and so on.
You can also use N to go back a file.
(For these commands to work, you'll need to first type /^diff
and press Enter, as explained in this answer.)
For other useful commands type h
for help (while being in git diff
, which is being in 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>
I'd suggest you to use tig
. It's a curses interface for git
, and a very good one.
With tig status
you can see the index status, and by pressing Enter on any of the files, you see it's diff. h shows you the help menu, but it's a vi-shortcuts-based interface.
I think in any debian-based distro you can just apt-get install
it, or you can make it from the linked site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With