1
votes

I am looking at automating the deployment of the code in Powershell environments.

I can easily execute the following command in a real session to get the code of a repository updated:

C:\path\to\PortableGit\git-bash.exe -c 'git -C  /c/path/to/repository.git pull' 

However we don't want to log into a session to update the code.

We have created a Service that will be in charge of updating the repository. The issue is that this command works from a real session, but it does not work from a service - it just hangs up.

I believe is because git-bash.exe requires to open a new Window with bash for a brief amount of time while the command is actually executed.

How can I execute this command from a Service ? Is there any other reasonable alternative ?

2

2 Answers

0
votes

Try wrapping the path in quotations and adding the call operator & at the beginning

& "C:\path\to\PortableGit\git-bash.exe" -c 'git -C  /c/path/to/repository.git pull'
0
votes

Well, finally I saw no other way than using the git.exe rather than bash-git.

Therefore converting the command to the windows native will do the trick. If you have set up the private key authentication, you just need to set up the HOMEPATH variable.

$env:HOMEPATH="\Users\Administrator";C:\path\to\PortableGit\bin\git.exe -C C:\path\to\repository.git pull'