I want to run a powershell script to push to git automatically every so often.
I have GitHub installed for windows. If I run "Git Shell", a powershell shell opens but it has the git function installed and starts in C:\Users\crclayton\Desktop\GitHub> not in H:\>
If I try to use git in a normal PowerShell, it tells me git isn't recognized as a function. However, if I load the script C:\Users\crclayton\AppData\Local\GitHub\shell.ps1 in the normal powershell, I can use git, but when I navigate to the folder and try to add or commit or push, I get the error:
git.exe : fatal: unable to access
'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
This is my code:
#(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
Can anyone see what's wrong or suggest an alternative? Thanks in advance.
