Checking for uncommited git changes in a batch program

July 22, 2020 batch, git

Sometimes it's helpful to exit out of a batch script if there are pending changes to a repo. This is done in batch script in a non intuitive way.

PUSHD %~dp0


REM The loop won't be executed if 'git status -s' doesn't produce any output.
FOR /f "tokens=*" %%i IN ('git status -s') DO ( SET __HAS_CHANGES=1 )

REM Check if the loop was executed and goto EXIT if it was.
IF "%__HAS_CHANGES%" NEQ "0" (
    ECHO There are currently uncommitted changes.

REM Do the work you want to do here.


Git Quick Push

March 29, 2018 git, batch

Here's a quick one liner to quickly stage all your changes in the current git repo, commit them and then push the commit to origin master branch.

Read More

Switching from Git to Mercurial

June 03, 2011 git, Mercurial

I've decided to make the switch from using git to Mercurial. Git's syntax to me is much more complicated than it needs to be and Mercurial seems to be more my style. I find it's much easier to find out how to do things with Mercurial and to be honest, I use about 10% of the functionality in either git or Mercurial.

This also means I'll be transitioning Snowball to Codeplex I think. I'll be moving it away from GitHub for sure just not 100% sure where.

Using git-gui with Cygwin on Windows 7

April 07, 2011 Cygwin, git, git-gui, Windows 7

I've started using git via cygwin and was running into trouble trying to pin it to my taskbar in Windows 7.

First I created a .bat file in the c:\cygwin folder which launches the app standalone:

@@echo off

chdir C:\cygwin\bin

start run.exe git gui

You can change paths accordingly. Now run the batch file and pin the program to the taskbar. You'll notice after you close the app, the icon changes and it won't launch again.

Right click on the shortcut while holding shift and choose properties. Change the target to the batch file we wrote. You can change the icon to the git-gui icon by pointing the shortcut icon to "C:\cygwin\usr\share\git-gui\lib\git-gui.ico".

Now if you click on the icon, the git-gui app should start up. Kill your explorer.exe in task manager and restart. If the icon is still the genie lamp, you'll need to clear your icon cache to get the icon to look right. Credit for that from here. Kill your explorer.exe again and while explorer is gone, start cmd.exe. From there enter the following commands:

CD /d %userprofile%\AppData\Local

DEL IconCache.db /a


After that your icon should be there as you want.