Can';t在“范围”内使用管道;git.exe获取源文件“;在Windows下批处理
我编写了一个批处理来检查和部署github中的rails应用程序,批处理文件见下文。问题是Can';t在“范围”内使用管道;git.exe获取源文件“;在Windows下批处理,windows,git,batch-file,pipe,Windows,Git,Batch File,Pipe,我编写了一个批处理来检查和部署github中的rails应用程序,批处理文件见下文。问题是git.exe fetch origin | find“remote:Counting Objects”总是返回errorlevel 1,即使我们有新的提交。我必须先终止Rails应用程序,因为某些文件被锁定(*.jars),并导致git pull命令失败 我搜索并找到了下面的主题,但即使使用git.exe而不是git.cmd,问题仍然存在。 我尝试使用一个临时文件来存储git.exe fetch
git.exe fetch origin | find“remote:Counting Objects”
总是返回errorlevel 1
,即使我们有新的提交。我必须先终止Rails应用程序,因为某些文件被锁定(*.jars
),并导致git pull
命令失败
我搜索并找到了下面的主题,但即使使用git.exe
而不是git.cmd
,问题仍然存在。git.exe fetch origin
result,但是如果这个命令似乎总是将结果打印到控制台
此外:
git pull | find "Already up-to-date."
if %errorlevel% == 1 (
很好
REM @echo off
set path=%path%;C:\Program Files\Git\bin;D:\jruby-1.6.7\bin
set JRUBY_OPTS=--1.9
git.exe fetch origin | find "remote: Counting objects"
if %errorlevel% == 0 taskkill /f /im:jruby.exe
git pull | find "Already up-to-date."
if %errorlevel% == 1 (
REM
start cucumber.bat
REM do something else when update
)
REM RAILS
tasklist | find "jruby.exe"
if %errorlevel%==1 (
echo @rails s > rail.bat
echo @exit >> rail.bat
start cmd /c rail.bat
)
exit
REM@回声关闭
设置路径=%path%;C:\ProgramFiles\Git\bin;D:\jruby-1.6.7\bin
设置JRUBY_OPTS=--1.9
git.exe获取来源|查找“远程:计数对象”
如果%errorlevel%==0 taskkill/f/im:jruby.exe
git pull |查找“已经是最新的”
如果%errorlevel%==1(
雷姆
开始吧,蝙蝠
REM在更新时执行其他操作
)
REM轨道
任务列表|查找“jruby.exe”
如果%errorlevel%==1(
echo@rails s>rail.bat
echo@exit>>rail.bat
启动cmd/c rail.bat
)
出口
我猜这是因为“计数对象”行显示了一个动态的进度指示器,所以我会说它正在崩溃,但请不要引用我的话
...
git fetch origin
git branch -a --no-merged |find "remotes/origin"
if %errorlevel% == 0 taskkill /f /im:jruby.exe
...
您可能还希望将其仅限于当前分支:
git branch -a --no-merged |find "remotes/origin/mybranch"
谢谢,git branch-a——没有合并的| find“remotes/origin/HEAD->master”现在可以正常工作了。