我创建了一个钩子(post-commit)来运行.bat文件,并在这个文件中推到当前的brach。当我手动运行.bat时,它可以正常工作,但是当它按钩子启动时,它会抛出异常。
“当前dir”(现行dir)在两种情况下都是相同的。
后承诺
#!/bin/bash
cd ./.git/hooks
start post-commit.batpost-commit.bat
@ECHO OFF
Echo Current dir: "%CD%"
set /p yn=Push to current brach immediately[Y/N]?
if "%yn%"=="y" goto y
if "%yn%"=="n" goto n
if "%yn%"=="Y" goto y
if "%yn%"=="N" goto n
goto error
:error
cls
echo That is not a recognized choice.
pause
exit
:y
echo Starting push...
git push
pause
exit
:n
exit .bat输出
Current dir: "c:\Users\Dan\Documents\Ambro\Areus\_Areus - Employee - PC\_Areus -
Employee - PC\.git\hooks"
Push to current brach immediately[Y/N]? y
Starting push...
fatal: Not a git repository: '.git'发布于 2014-11-26 06:44:58
经过几个小时的失眠,我解决了。我必须编辑一下钩子。
后承诺
#!/bin/bash
cd ./.git/hooks || exit
unset GIT_DIR
start post-commit.bathttps://stackoverflow.com/questions/27137069
复制相似问题