Remote PowerShell script hangs when running `git push`

700 Views Asked by At

I've run Enter-PSSession successfully to connect to a remote server, and run several commands successfully too, like git add -u and git commit -m "xxx" etc.

but when trying to push the code using git push command, the shell then blocked forever unless exit with "Ctrl+C".

however I can remotely run git push from remote desktop program successfully without inputing any password.

is it because inputing username and password is needed in this case?

any way to solve/workaround it? thanks

1

There are 1 best solutions below

4
On BEST ANSWER

You can provide the username and password in the Git URL, either by configuring it in the config in advance:

git config remote.origin.url https://username:[email protected]/somerepo/somerepo.git

or within your push:

git push https://username:[email protected]/somerepo/somerepo.git