我想运行一个powershell脚本,以便定时自动推送到git。
我已经安装了GitHub for Windows。如果我运行“Git Shell”,则会打开一个powershell shell,但它已安装git
函数,并且从C:\Users\crclayton\Desktop\GitHub>
开始而不是H:\>
如果我尝试在普通的PowerShell中使用git
,它会告诉我未能识别git作为函数。然而,如果我在普通powershell中加载脚本C:\Users\crclayton\AppData\Local\GitHub\shell.ps1
,那么就可以使用git
,但当我导航到文件夹并尝试add
或commit
或push
时,我会得到以下错误:
git.exe:致命错误:无法访问
'Microsoft.PowerShell.Core\FileSystem::\mypath../.config/git/config': Invalid argument At
C:\Users\crclayton\Desktop\autogit.ps1:7 char:4
git <<<< add *
CategoryInfo : NotSpecified: (fatal: unable t...nvalid argument: String) [], RemoteException
FullyQualifiedErrorId : NativeCommandError
这是我的代码:
#(Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1") # tried this, doesn't work
C:\Users\crclayton\AppData\Local\GitHub\shell.ps1
$msg = Read-Host "Enter commit msg"
cd "C:\Users\crclayton\project\"
git add *
git commit -a -m $msg
git push origin master
有人能看到问题在哪里或者提出替代方案吗?先谢谢了。
git.exe
藏在以下文件夹中后才成功:C:\Users\crclayton\AppData\Local\GitHub\PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad\bin
。 - Charles Clayton