Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

diffing unstaged or uncommitted changes in IntelliJ Idea

In the IntelliJ Idea IDE, how do I do the equivalent of plain ol' git diff (ideally git diff -w) or git diff --staged, so I can view my changes side-by-side with my branch's HEAD? I basically want the same thing as Project Explorer → Compare With → HEAD Revision in Eclipse Juno.

I've found out how to compare different branches in IntelliJ, but I haven't worked out how to do this basic thing―the current branch does not appear as an option in Project tree → Git → Compare with Branch.... An answer below explains how to do it for one file, but this doesn't work for the whole project or even an individual directory, only individual files.

I'm using IntelliJ for the first time in 8 years, so I'm probably missing something obvious. Unfortunately, the resident IntelliJ expert is completely new to Git. ;-)

like image 964
Michael Scheper Avatar asked Mar 28 '14 00:03

Michael Scheper


People also ask

How do I see uncommitted changes in IntelliJ?

IntelliJ IDEA allows you to review all changes made to the project sources that match the specified filters. For distributed version control systems, such as Git and Mercurial, you can view project history in the Log tab of the Version Control tool window Alt+9 (see Investigate changes in Git repository).

How do I undo uncommitted changes in IntelliJ?

Revert uncommitted changes You can always undo the changes you've made locally before you commit them: In the Commit tool window Alt+0 , select one or more files that you want to revert, and select Rollback from the context menu, or press Ctrl+Alt+Z .

How can I see commit history in IntelliJ?

IntelliJ IDEA lets you review the state of your project at a selected revision. Open the Git tool window Alt+9 and switch to the Log tab. Select a commit and choose Show Repository at Revision from the context menu.


1 Answers

You can see the diff of the opened file by going to Main Menu -> VSC -> GIT -> Compare with same Repository Version.

There is also a shortcut enter image description here in the toolbar, using which you can directly view the diff of the opened file.

like image 133
msfk Avatar answered Sep 26 '22 02:09

msfk