我正在尝试将代码备份自动化为git,但收效甚微.在这种情况下,我在perl中尝试它.我目前的问题是git在运行时希望在正确的目录中.(注意第三行.)我收到错误:致命:无效的refspec'dest = c:\ data\git\aperio\Scratch\src\rich' 有没有办法将我的目录定义为arg?或者在指向目录的环境中运行失败?
注意:我认识到这对大多数git命令都是一个问题,而不仅仅是拉动.
...
@file=("deploy*.bat","deploy.ini","product.lic");
system("$gitexe checkout integrate");
system("$gitexe pull url=https://github.com/Aperio/aperio/Scratch/src/rich dest=c:\\data\\git\\aperio\\Scratch\\src\\rich");
exit if ($testing);
my $message="Changed: ";
foreach $file (@file) {
my ($src,$git,$timestamp,$sb,$message);
my @files = glob($file);
foreach my $f (@files) {
$git=$gitdir."\\rich\\".$f;
say $git;
# Update git if needed
if ((stat($git))[9] < (stat($f))[9]) {
$message.="$f, ";
system("robocopy.exe . $gitdir /R:3 /Z /XO $f"); # Copy file to git folder
system("$gitexe add $gitdir\\rich\\$f");
}
}
}
system("$gitexe commit -m $message");
system("$gitexe status");
system("$gitexe push origin ");
Run Code Online (Sandbox Code Playgroud)
是的,你可以设置的GIT_DIR环境变量或--git-dir选项告诉混帐东西.git使用目录.
use Git;
my $repo = Git->repository(Directory => '/srv/git/cogito.git');
$repo->command("commit", "-m", $message);
Run Code Online (Sandbox Code Playgroud)
这避免了许多问题,如shell转义,错误处理,捕获输出和忘记设置--git-dir.
| 归档时间: |
|
| 查看次数: |
773 次 |
| 最近记录: |