UNC 的 Git 获取错误 [英] Git Fetch Error with UNC

查看:21
本文介绍了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: \backupnasackup
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 服务器将其作为计划任务运行时,它立即存在(非常类似于问题 https://serverfault.com/questions/343496/powershell-script-works-from-command-line-not-from-task-调度器-为什么)这给了我一个想法,检查天气 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.

根据问题:UNC 路径上的 git 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(从 master 所在的配置文件中读取)

  • 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 获取错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆