Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git asks a password for a wrong URL

After creating a repository at GitHub, I follow the instruction given by GitHub:

$ echo "# test" >> README.md
$ git init
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin https://github.com/user/test.git
$ git push -u origin master

(In the above URL the actual user name is replaced with user.)

Then I am asked (by Ksshaskpass) about

Password for 'https://[email protected]':

(The user name is not asked.) This xxxxxxxx is actually the initial password which I used when I created an account at GitHub. And my password is denied, so that I can not push the data.

I am expecting the output like the following.

$ git push -u origin master
Username: <username>
Password: <password>

I removed ~/.gitconfig, but the situation does not change. (The username is not asked yet.) There does not exist the directory ~/.git. So I suspect that there is a wrong configuration file which I created a long time ago, but I can not find it.

Could you give me any hint about this phenomenon?

Env: openSUSE 13.2, git-2.1.4-13.1.x86_64

like image 289
H. Shindoh Avatar asked Jul 07 '15 20:07

H. Shindoh


1 Answers

Change the remote url to ssh.
https will keeep asking you for password every time you wish to run git pull/push/fetch.

Simply follow those steps and you will set up your ssh key in no time:

  • Generate a new ssh key (or skip this step if you already have a key)
    ssh-keygen -t rsa -C "your@email"

  • Once you have your key set in home/.ssh directory (or Users/<your user>.ssh under windows), open it and copy the content


How to add sh key to github account?

  • Login to github account

  • Click on the rancher on the top right (Settings)
    github account settigns

  • Click on the SSH keys
    ssh key section

  • Click on the Add ssh key
    Add ssh key

  • Paste your key and save

  • Change the remote url git remote set-url origin <new_ssh_url>

And you all set to go :-)

like image 102
CodeWizard Avatar answered Nov 15 '22 08:11

CodeWizard