Skip to content

Instantly share code, notes, and snippets.

@TonyWhitley
Created November 16, 2023 16:51
Show Gist options
  • Save TonyWhitley/caf7d3275759690fd3d652e1d11f5cc9 to your computer and use it in GitHub Desktop.
Save TonyWhitley/caf7d3275759690fd3d652e1d11f5cc9 to your computer and use it in GitHub Desktop.
Compare local file with the file in another git branch
@echo off
setlocal
echo Compare local file with the file in another git branch
echo.
set /p branch=Branch to compare to? :
set /p file=File? (relative to repo root, use \ for paths) :
set file=.\%file: =%
rem %file: =% removes any spaces (aimed at trailing spaces)
if exist %file%.%branch% (echo temp file %file%.%branch% already exists
pause
goto :eof)
git show %branch%:./%file% > %file%.%branch%
**insert path to your favourite compare tool here** %file% %file%.%branch%
rem Tidy up
del %file%.%branch%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment