The command :Gdiff
is equivalent to running git diff
on that file.
What's the equivalent for git diff --staged
or git diff --cached
?
git diff --staged will only show changes to files in the "staged" area. git diff HEAD will show all changes to tracked files. If you have all changes staged for commit, then both commands will output the same.
If your changes are already staged, then there's no difference to show. But there's a command line option that will show you staged changes if you specify it: git diff --staged . With the --staged option, git diff will compare your staged changes against the previous commit.
The git diff command allows us to track the changes that are staged but not committed. We can track the changes in the staging area. To check the already staged changes, use the --staged option along with git diff command.
I've found a way to do this. Run :Gstatus
, you should get a window with contents like the following:
# On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: example.txt #
Scroll down to the staged file, example.txt
, and press Shift+D. This will open a diff view, comparing what's in HEAD and what's in the index. You'll notice on the bar on the bottom that both the filenames are special Fugitive filenames.
Also while in Gstatus preview window, you can press g?, which will list all the mappings valid in the current context.
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