获得最近一天的提交,并使用winscp上传到服务器

@echo off
D:\dev\Git\bin\git.exe pull origin master
D:\dev\Git\bin\git.exe add -A
D:\dev\Git\bin\git.exe commit -m someupdate
D:\dev\Git\bin\git.exe push origin master
set SESSION=sftp://user:password@ip:22
set LOCAL_PATH=D:\pro\yourproject\
set REMOTE_PATH=/public_html/
del list.txt
rem git diff --name-only HEAD~ HEAD >> list.txt 
git log --pretty=format: --name-only --since="1 days ago" >> list.txt 
echo open %SESSION% >> script.tmp
rem Generate "put" command for each line in list file
setlocal ENableDelayedExpansion
chcp 1250
for /F %%i in (list.txt) do (
set str=%%i
call set str=%%str:/=\%%
echo put "%LOCAL_PATH%!str!" "%REMOTE_PATH%%%i" >> script.tmp
)
echo exit >> script.tmp
winscp.com /script=script.tmp
set RESULT=%ERRORLEVEL%
del script.tmp
rem Propagating WinSCP exit code
exit /b %RESULT%

  

posted @ 2019-03-21 09:55  meetrice  阅读(253)  评论(0编辑  收藏  举报