How to compare a single file across git branches while keep on editing

Viewed 108

I am looking for the way to compare single file from the current workspace in VSCode to itself in a different branch of git repository.

Important that I need to be able to continue editing current workspace file while observing the differences, so you get live diff as you go. VSCode has no problems of comparing this way with previous commit for example, but not the other branch.

I have tried a number of VS plugins, the closest I could get was with "Git History Diff" plugin. It has shown me the diff I wanted, but unfortunately in read only mode.

1 Answers

You can run the following command in the terminal window:

watch -n 1 git diff your_different_branch -- your_file

which will continously update the diff every second.


If you're on windows, I do not remember if Git bash has watch included, but if not it probably is included in cygwin.

Related