Muhammad Umer
Muhammad Umer

Reputation: 18127

How to close the git diff panel in vscode?

Is it possible, preferably using a shortcut, to close a git diff window in vscode. I know you can close the sidebar by pressing the ctrl/cmd + B. What about the file git diff window. That shows working file on right and original file on the left.

The reason is that I may have bunch of files and then I go to see what have I changed and see one file. I see something I want to fixed in it and then start editing it but there is left window showing git diffs which I just want to close. But pressing x on file name closes everything both the current version of file and last committed version.

I guess another way to ask this question would be how to go from git diff window to file directly.

enter image description here

Upvotes: 9

Views: 11437

Answers (6)

Konstantin Samkowskiy
Konstantin Samkowskiy

Reputation: 41

Might be useful: there is a extension Diff Tab Auto Close in vscode which auto closes diff tab when it loses focus, very convenient for me

Upvotes: 1

princebansal_
princebansal_

Reputation: 163

You can set your custom shortcut for closing git diff editor panel following below steps:

  1. Open Command Palette cmd + shift + p
  2. Type git close, you'll see Git: Close All Diff Editors and in extreme right you'll see setting icon, click on it
  3. Set your custom shortcut, e.g: cmd+g cmd+w

This is way you can close git diff panel efficiently.

screenshots: icon

PS: Git diff editor panel is just another file opened in your editor, so instead of using above steps you can simply do cmd + w, it will close the git diff file like we normally do for any other file.

Hope it helps!

Upvotes: 1

Brad
Brad

Reputation: 11

The Diff window shows when you are in the Source control section. If you want to just see the file (which it the right-hand side of your image) navigate to the folders section and click on your file.

Upvotes: 0

Mark
Mark

Reputation: 182441

"I guess another way to ask this question would be how to go from git diff window to file directly."

There is a new command to do what you want coming in vscode v1.75:

workbench.action.compareEditor.openSide

It is currently in Insiders v1.75 and works well.

It is bound to Ctrl+K Shift+O by default but you can change that.

So whichever side of the diff has focus when you trigger the command, the diff will be closed but that file will be opened in its own editor.

See Allow to open either side of a diff editor as editor.

Upvotes: 4

VonC
VonC

Reputation: 1327784

VSCode 1.65 (Feb. 2022) - Release Notes > Diff Editor Management

There is a new command Git: Close All Diff Editors in the Command Palette that can be used to close all open diff editors.

There is also a new setting, git.closeDiffOnOperation to automatically close diff editors when changes are stashed, committed, discarded, staged, or unstaged

Related Issues:

Upvotes: 12

Mario Vargas
Mario Vargas

Reputation: 74

You can make a right click with the mouse on the file that you want to modify and click in the "Open File" option.

Figure 1

Upvotes: 2

Related Questions