Skip username prompt when using git

7

4

Is there a way to skip the username prompt when I git pull? I read about skipping the entire authentification e.g. with the help of keys or ssh agents. However, I only want to send my username. Is this somehow possible?

I contribute to a private repo a friend shared with me - if that matters. My user.name is written in the global git config and I use https protocol for the remote.origin.url.

MERose

Posted 2014-12-01T16:09:41.723

Reputation: 205

Answers

11

For both HTTP(S) and SSH, the username can be specified as part of the URL in user@host form:

  • https://user@example.com/repo.git

  • user@example.com:repo.git

    (Yes, git@github.com means that the SSH username is always git when using GitHub.)

  • ssh://user@example.com/repo.git

If necessary, use git remote set-url or directly edit the .git/config file.

user1686

Posted 2014-12-01T16:09:41.723

Reputation: 283 655

2

Easiest Solution:

From your git root directory, edit the config file .git/config.

You should see a section that looks like the following:

[remote "origin"]
        url = https://xxx.xxx/xxx/xxx.git

What you want to do is add your username@ directly after the https://. As such:

[remote "origin"]
        url = https://username@xxx.xxx/xxx/xxx.git

Save and close this config file, and Git will no longer prompt you for your username when within that repo.

Joe Be

Posted 2014-12-01T16:09:41.723

Reputation: 21