I am writing a batch file to automatically add my modified files to the staged area in git.
The batch file is situated in my dev/tools directory takes the directory of the git repo as it’s first argument.
This is my code at the moment:
@echo OFF
IF "%1"=="" (
echo No directory supplied...
goto :exit
) ELSE (
echo Adding all modified files to staged area for %1
git add %1
)
:exit
However, when I’m in the dev/tools directory and run ./test.bat ../temp I get the following output:
Adding all modified files to staged area for ../temp
fatal: Not a git repository (or any of the parent directories): .git
How can I perform ‘git add .’ on a repo situated in a directory that I’m not currently inside using a batch command?
Do a
cd %1first before you execute git add