How to open all files at once using VS Code as a Git difftool and mergetool?
Asked Answered
C

3

2

Currently, I have VS Code configured to be my git difftool and git mergetool

My ~\.gitconfig file looks like this:

[user]
    email = [email protected]
[merge]
    tool = vscode
[mergetool "vscode"]
    cmd = code --wait $MERGED
[diff]
    tool = vscode
[difftool "vscode"]
    cmd = code --wait --diff $LOCAL $REMOTE

However, when I run git difftool, it will ask me

Viewing (1/6): 'Repo\directory\someCode.cs'                                                                                                                 
Launch 'vscode' [Y/n]?

Is there a way to open all diffs at once? It is useful to be able to cycle between files without having to close them.

Cattle answered 24/1, 2020 at 20:10 Comment(1)
O
1

The easy way I found is:

  1. Adding an alias for the .bashrc file located in /home/.bashrc (Debian/Ubuntu distro).
  2. At the end add the line alias difftool="git difftool -y" and save it.
  3. Reload the bash with the command source ~/.bashrc from the terminal.
  4. Try to run it again.
Overside answered 27/5, 2020 at 16:14 Comment(1)
Hmm. I'm on Windows. I'll have to think about how to do the equivalent in PowerShell.Cattle
D
1

Check if VSCode 1.53 (Jan. 2021) can help:

Git: New command "Open All Changes":

A new Git command has been added to the Command Palette:

Git: Open All Changes... - Opens all modified and untracked files.

That way, you can directly check changes from VSCode instead of calling VSCode from the command-line though git difftool as I suggested initially in the comment (git difftool --dir-diff).

Degrading answered 1/2, 2021 at 7:48 Comment(2)
Any chance you have an example of how to configure it? I'm not real well versed on manipulating git config files.Cattle
@KolobCanyon The idea behind that answer is to not manipulate git config files, but simply call this new command (in VSCode 1.53 not yet released)Degrading
I
-1
git difftool -d master..prod

This works better

Improvise answered 13/5, 2023 at 17:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.