本文介绍了UNC的Git提取错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GIT备份脚本,当从命令行执行时,它可以完美运行(这是我们主要GIT代表的每日备份):

I have a GIT backup script that runs perfectly when executed from command line (it's a daily backup of our main GIT rep):

@echo off
rem -- Set Parameters
rem -- daliy GIT backup
REM Get DATE
set mm=%Date:~4,2%
set dd=%Date:~7,2%
set yy=%Date:~10,4%
set TODAY=%yy%%mm%%dd%
for /f %%a in ('date /t') do set DAY=%%a
if %DAY%==Sun goto :weekend
if %DAY%==Sat goto :weekend
goto :weekday
:weekend
:: No backup after weekends
echo %day%
exit
:weekday
:: Backup during weekdays
REM Connect to share
REM net use z: \\backupnas\backup\
Z:
cd \
cd git
REM Start backup of current GITS
cd OptiTexRepo.git
call git fetch
cd ..
RAR.exe a -rr10 -s ARCHIVES\%TODAY%.OptiTexRep.git.rar OptiTexRepo.git
cd OptiTexRepo_V11.1.git
call git fetch
cd ..
RAR.exe a -rr10 -s ARCHIVES\%TODAY%.OptiTexRepo_V11.1.git.rar OptiTexRepo_V11.1.git
REM exit

但是,当我从W2008R2服务器每天都会立即存在(非常类似于问题)
我有一个主意,可以检查天气GIT FETCH是否可以在UNC上正常工作-显然可以,但是在任务中运行时-出了点问题-我不知道是什么。

However, when I run it as a scheduled task from a W2008R2 server, on a daily basis, it immediately exists (very similar to question https://serverfault.com/questions/343496/powershell-script-works-from-command-line-not-from-task-scheduler-why)That gave me an idea, to check weather GIT FETCH works correctly with UNC - apparently it does, but when running in a task - something is wrong - and I can't figure what.

根据问题: git应该可以,但是我不明白

According to question: git on UNC path git should work, but I don't understand what needs to be the script command in order for it to actually work.


  • 当前,我将备份驱动器映射到Z :,当我将CD放入文件夹时,我只需GIT FETCH(即从配置文件中读取

  • Currently I map my backup drive to Z:, and when I CD to the folder, I simply GIT FETCH (that reads from the config file where the master is)

如何使用UNC做到这一点?

How can I do that with using UNC? that will also work from the task scheduler?

还是这个问题实际上在其他地方?

Or is the problem actually somewhere else?

推荐答案

Git可以使用UNC路径,但通常将它们用作Unixy路径更可靠-因此 git clone //例如backupnas / backup / repo.git

Git does work with UNC paths but typically it is more reliable to use them as Unixy paths - so git clone //backupnas/backup/repo.git for instance.

作为任务运行时-检查权限是否允许您的任务看到具有读取访问权限的远程路径。除此之外-脚本中有很多回声,并测试运行命令的结果代码。对于最新版本的msysGit,您可能不再需要调用git,因为包装器git.cmd已更改为git.exe来解决一些带有^字符的引用问题。

When running as a task - check that the permissions will allow your task to see the remote path with read access. Other than that - lots of echo's in the script and test the result codes for running commands. For the most recent version of msysGit you may not require the 'call git' anymore as the wrapper git.cmd got changed to a git.exe to resolve some quoting problems with ^ characters.

这篇关于UNC的Git提取错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 04:01