3

I'm trying to use a username and a password for a git push but I cannot find the options to use with the git command.

I've tried: http://username@gitserver/project

Can anyone help?

nwinkler
  • 52,665
  • 21
  • 154
  • 168
mohamed wael thabet
  • 195
  • 2
  • 4
  • 12
  • possible duplicate of [Git push : username , password, how to avoid](http://stackoverflow.com/questions/8588768/git-push-username-password-how-to-avoid) – Vishwanath Feb 23 '15 at 10:59
  • possible duplicate of [Git Push Error: insufficient permission for adding an object to repository database](http://stackoverflow.com/questions/6448242/git-push-error-insufficient-permission-for-adding-an-object-to-repository-datab) – Matt Apr 22 '15 at 13:57

2 Answers2

2

Typically, you don't provide the credentials in the URL. It's OK to have the username in there like you did - Git will then ask for the password.

You could try adding the password like this, but it's not a good idea, since it means having the password in plain text, issues with special characters/encoding, etc.:

http://username:password@gitserver/project

I'm not sure what you're trying to do, but in general, it's better to use a credential helper to store passwords so you don't have to reenter them every time: https://help.github.com/articles/caching-your-github-password-in-git - this page has instructions for the most common operating systems.

nwinkler
  • 52,665
  • 21
  • 154
  • 168
1

Git leaves authentication to the used protocol, like ssh or http in your case, therefore the authentication method may not even be password-based.

I presume you want to do automatic authentication, in that case you can use key-based ssh. Github has an example how to do that. If you're rolling your own Git server, then you need to add your key fingerprint to the authorized_keys, see the relevant question.

Community
  • 1
  • 1
Marek Vavrusa
  • 246
  • 1
  • 7