Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (29.3k points)

I staged a few changes to be committed; how can I see the diff of all files which are staged for the next commit? I'm aware of git status, but I'd like to see the actual diffs - not just the names of files that are staged.

I saw that the git-diff(1) man page says

git diff [--options] [--] […]

This form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you could tell git to further add to the index but you still haven't. You can stage these changes by using git-add(1).

Unfortunately, I can't quite make sense of this. There must be some handy one-liner which I could create an alias for, right?

1 Answer

0 votes
by (50.2k points)
edited by

You can use --cached option which shows you the staged changes in cache/index

git diff --cached

--staged is the synonym for --cached

These will not point to HEAD, but it just shows the difference with respect to HEAD.

If you want cherry-pick to commit using

git add --patch --staged

This command will show you what is staged.

For more information please go through the following tutorial to get more info about git:

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 22, 2019 in DevOps and Agile by humble gumble (19.4k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...