2

is there any way to provide username and password for git pull as command line arguments? in svn there was something like:

svn up --no-auth-cache --username $SVN_USER --password $SVN_PASSWORD

Is there any equivalent of this in git? I can't store the credentials on the filesystem.

Basically, I have a script running build for multiple correlated projects. Because the script is on a shared server and is to be run by different users, I can't store the credentials on the server. I don't want to prompt the user, because the script fetches data from multiple SVN/GIT repositories with single username/pass so I want to read the credentials once via the script and then pass them to git pull or svn up commands

Kamil Roman
  • 973
  • 5
  • 15
  • 30

1 Answers1

0

If you're using HTTPS, a solution might be in this answer:

The not secure way is to include credentials in the url you're pulling, https://user:password@server.com/path/to/repo. Apparently, your credentials end up as plain text in the .git folder and/or in log files.

The secure way is to configure a "credential helper" in git. Then it will remember the credentials once they're used. It will store the credentials securely on the machine, but if you use the system-wide configuration they will apply to all users. For example, with msysgit on Windows I'd use the wincred helper: git config --system credential.helper wincred. My understanding is that --system turns the credential helper on for all repositories and all users on the system, so you'll have to decide if this is okay for your server. Disclaimer: I've only used --global before.

I haven't seen better options for your situation, but some of the real git gurus might chime in.

Community
  • 1
  • 1
Vimes
  • 10,577
  • 17
  • 66
  • 86
  • Unfortunately, I don't want to store the password anywhere – Kamil Roman Aug 07 '15 at 07:30
  • So, the script must run `git pull` when logged into the machine as other users, but those users are not allowed to run the command manually? That sounds impossible to do securely for any program, including SVN. Did you find a way? – Vimes Aug 07 '15 at 16:32
  • 1. We have single OS user for all the builds 2. Different physical users should not have access to git accounts of other users, which would happen if using the credential helper. I will post my workaround. – Kamil Roman Aug 07 '15 at 18:05