11

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

6 Answers 6

12

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:

Sign up to request clarification or add additional context in comments.

Comments

5

"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.

1 Comment

Nice! I will definitively use that one.
2

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

1 Comment

I used this, stackoverflow.com/questions/44737285/…, and set my keys to cmd+shift+i for both going in and out of git changes/diff view
2

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!

Comments

1

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

Comments

0

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.

1 Comment

Welcome to stackoverflow! Unfortunately, the author of this specific question is asking for a directly, so without reselecting it from the folder view.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.