Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git clone in .bat script

Tags:

git

batch-file

Is it possible to write a Windows .bat script that executes "git clone" in the middle of the script, so that the script continues? It is always exiting for me.

I am using a 64-bit Git version 2.8.3 from "The Git Development Community" on Windows 7 Enterprise SP1. git.exe is in my path (c:\program files\git\cmd\git.exe) - it is not indirectly executing via a git.cmd or similar file.

I am able to run a sequence of commands like

git init
git add --all
git commit -m "commit message"

and with these commands, the batch script executes each command continues normally. With

git clone {url}

the script exits immediately, usually with a doubled prompt, suggesting some sort of abnormal exit (even though %ERRORLEVEL% is 0):

git clone {url} new
Cloning into 'new'...
remote: Counting objects: 26, done
remote: Compressing objects: 100% (23/23) done.
remote: Total 26 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (26/26) done.
Checking connectivity... done.
c:\jdev\ppss\finalprep\ant2>c:\jdev\ppss\finalprep>

Common Windows tricks like using "call git clone ..." and "cmd /c git clone ..." do not seem to work. Even "start /wait cmd /c git clone ..." doesn't do it.

Any ideas?

like image 457
John Elion Avatar asked Sep 06 '16 12:09

John Elion


1 Answers

In the specific case that was failing, the subdirectory into which "git clone" was writing already existed due to a prior "mkdir". Without the mkdir - without the subdir already existing - the batch script continues after git clone normally, and there was no need for any special tricks like cmd /c

like image 178
John Elion Avatar answered Oct 11 '22 19:10

John Elion