Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View unstaged diff from git interactive add

Tags:

git

I'm using Git add's interactive mode (git add -i) for the first time and have a question about the diff command it offers. By default, it shows a diff for changes I've already staged (equivalent to using git diff --staged). Is there a way to make it show a diff of unstaged changes? This would be really helpful for when I need to selectively add some files for staging and want to see the changes I made before adding them. I would like to do this without leaving interactive mode or having another terminal open to do a regular git diff.

like image 557
Phil K Avatar asked May 23 '16 12:05

Phil K


1 Answers

With git add -p or the patch option of git add -i you see the individual changed hunks before you decide whether to stage them or not. You can also change between the unstaged hunks of a file before deciding whether to stage hunks or not.

like image 63
Vampire Avatar answered Oct 26 '22 20:10

Vampire