Search code examples
gitstack-overflowpsexec

Unable to pull from git in psexec mode


Everything is working fine when I am pulling from local login but when I tried to login to Windows 7 git version 2.28.0.windows.1 through PSEXEC, and tried to pull the changes it is displaying

git.exe :
+ CategoryInfo          : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

Process is terminated due to StackOverflowException.
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No such file or directory

this is only happening when I tried to pull from PSEXEC mode even though I am also logged in as an administrator and through the same local account.


Solution

  • That error could be linked to:

    • a private repository (meaning you need authentication for each Git remote command like a pull)
    • a credential helper (check what git config credential.helper return through psexec)

    If there is an interactive process asking for the username, try as a workaround/test to include said username in the HTTPS URL:

    git remote set-url origin https://<username>@github.com/<username>/<myrepo>
    

    The OP Siva Manasan reports in the comments it works when specifying both the username and password.

    git remote set-url origin  https://<username>:<password>@github.com/<username>/<myrepo>.git
    

    Ideally, if a recent enough version of Git for Windows (and its associated microsoft / Git-Credential-Manager-for-Windows) is installed on the remote machine accessed by psexec.

    First check where Git is installed on the remote machine:

    psexec <...parameters for remote machine> where git
    

    Then use the remote credential helper to register the password:

    psexec <params> [path\to\git]\mingw64\libexec\git-core\git-credential-manager.exe store < afile
    
    # with afile:
    protocol=https
    host=github.com
    username=some-account
    password=personaltoken
    

    Note: it is better to use a PAT (Personal Access Token) than your actual password: safer, and you can revoke the PAT at any time without having to change the password.

    Then a simple URL with only your username should be enough:

    git remote set-url origin  https://<username>@github.com/<username>/<myrepo>.git