gitpowershellwinrmwinrs

Remote PowerShell script hangs when running `git push`


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


Solution

  • 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:password@somegiturl.com/somerepo/somerepo.git
    

    or within your push:

    git push https://username:password@somegiturl.com/somerepo/somerepo.git