Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am working with a repo on GitHub and everytime I try to push something, it asks for my GitHub username and password. I don't want it doing that.

I tried the instructions on setting your email in Git, namely set up the Git variables github.user and github.token, but that didn't make any difference.

I don't understand why this is happening.

share|improve this question
    
You need to cache the password: help.github.com/articles/set-up-git#password-caching –  Piotr Usewicz Jun 14 '12 at 19:59
add comment

7 Answers

up vote 5 down vote accepted

You need to set-up an ssh-agent against which you only need to authenticate once. See this answer over at SO for a howto.

share|improve this answer
    
But this solution is for ssh-family phrases. The problem is git uses "git push" which doesn't trigger the ssh-agent, I assume. (I've already done this, so I know it doesn't work.) –  picardo Oct 14 '10 at 18:27
1  
@picardo: I've done this, and it does indeed work. –  Daenyth Oct 14 '10 at 19:44
add comment

If you are on Windows using HTTPS, try the Git Credential Store - it uses the Windows Credential Store to hold your name and password.

Windows Credential Store for Git
This application is a small helper app designed to follow the 
git credentials API as defined by the Git Documentation.

Installation
1. Download the git-credential-winstore.exe application
2. Run it! If you have GIT in your PATH, it should just work.

Then the next time you enter your name and password it will remember them for you.

share|improve this answer
add comment

Also, if you wish to be prompted for your password every-time, but just not your username, then you configure the remote as HTTPS with a username.. Like this..

git config remote.origin.url https://USERNAME@github.com/repo_owner/repo_name

After this, you will be prompted for your password every time, but not your username.

This is how I prefer it, since I like being forced to type my github password before sharing with the world.

share|improve this answer
add comment

If you are using HTTPS instead of SSH , you can follow this :

  1. Find your remote URL (remote.origin.url) with

    git config -l
    

    thanks to Sergio Morstabilini

  2. Your remote URL will be like this : https://{USERNAME}@github.com/{USERNAME}/{REPONAME}.git

  3. Execute this command :

    git config remote.origin.url https://{USERNAME}:{PASSWORD}@github.com/{USERNAME}/{REPONAME}.git
    
share|improve this answer
add comment

As Piotr commented on the original post, there is a utility that you can use to enter your login only once. It will then remember your username/password forever in Git Bash.

See this link.

share|improve this answer
    
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. –  50-3 Dec 19 '13 at 4:56
    
Maybe you can't read well, THIS UTILITY is a solution to the problem presented in the question. I don't need clarifications. I have a solution. –  MK Safi Dec 19 '13 at 7:08
    
@MKSafi A summary of this link would be nice to make your answer self-contained –  Sathya Dec 19 '13 at 7:28
add comment

Had a similar problem today: I messed things up in my working copy, so I decided to rename the directory and clone my project again from github. But after doing that, I had to enter my password to do any pull/push request, instead of entering the passphrase just once as I used to.

That was because today I used the https protocol to clone the project! To check what protocol you're using just run

git config -l

and look at the line starting with 'remote.origin.url'.

To switch protocols:

git config remote.origin.url git@github.com:the_repository_username/your_project.git

the_repository_username and your_project should be replaced with the appropriate repository name and the owner of that repository. The username will be yours if you own the repository, or the repository owner's username otherwise.

share|improve this answer
4  
It worked for me. One thing is that the url does not my contain my username but the repo address as it appears on github: git@github.com:some-user/repo-name.git –  B Seven Feb 15 '12 at 7:04
    
Note: Google brought me here. I had the remote.origin.url set to the https method and didn't even notice there was https vs ssh methods. This URL helped me see the obvious: help.github.com/articles/… –  Chris K Jun 17 '12 at 3:31
    
Is there any way to pass password entering too? –  Alder Jul 30 '12 at 20:58
    
Q for those with git knowledge: Any difference (or preference) between git config remote.origin.url ... used above, vs. git remote set-url origin ...? –  Daryn Jan 9 '13 at 18:47
    
I could not figure how to remove a wrong origin like that. The answer is: git remote rm origin –  Vacilando Apr 7 '13 at 14:56
show 1 more comment

When you set up an ssh key for github, if it's not your default key, you will need to add a section to your ~/.ssh/config

Host *github.com
    User git
    IdentityFile ~/.ssh/github_id_rsa
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.