Honestly I haven't used this script recently, but it appears I did some modifications to it since the original version I posted. Here's my latest version. I'm not sure if this will resolve the issue you're seeing though. I suspect the bashruncmd.bat was the solution to what you described.
Edit: I also modified the custom action in SourceTree. It should look like this:
Script to Run: C:\git\tools\bashRuncmd.bat
Parameters: c:\git\tools\Stash_Staged.sh $REPO
Here's my bashruncmd.bat file:
SET mypath=%~dp0
start "C:\Program Files\Git\git-bash.exe" %1 %2 %3 %4 %5
And the updated Stash_Staged.sh script:
#!/bin/bash#!/bin/bash
#This script stashes only the staged changes.
#note when setting variables in bash you cannot have spaces:rootpath=$PWD
echo $1
#echo rootpath: $rootpath
thisscriptpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#echo thisscriptpath: $thisscriptpath
myargs=$'"Enter a message to describe the stash (cannot be empty): "'
tmpfile=$(mktemp)wscript.exe "$thisscriptpath\inputbox.vbs" $myargs >$tmpfileif [ $? -eq 0 ]then echo "User Clicked OK."else echo "User Clicked Cancel or closed the dialog." exit 1fi
InputBoxText=$(<$tmpfile)
echo InputBoxText: $InputBoxText
#After this multi stage process, any staged files will be stashed and unstaged files will remain.
#Stash everything temporarily. Keep staged files, discard everything else after stashing.git stash --keep-index
#Stash everything that remains (only the staged files should remain) This is the stash we want to keep, so give it a name.git stash save "$InputBoxText"
#Apply the original stash to get us back to where we started.git stash apply stash@{1}
#Create a temporary patch to reverse the originally staged changes and apply itgit stash show -p stash@{0} | git apply -R
#Delete the temporary stashgit stash drop stash@{1}
We are working on it.