Why is Github asking for username/password when following the instructions on screen and pushing a new repo?
I’m the owner of an organization on github and just created a repo and tried pushing but I’m running into an issue where it’s asking me for my username even though I can SSH just fine:
$ ssh -T firstname.lastname@example.org Hi Celc! You've successfully authenticated, but GitHub does not provide shell access. $ git add . $ git commit -m 'first commit' [master (root-commit) 3f1b963] first commit 6 files changed, 59 insertions(+) create mode 100644 .gitignore create mode 100644 main.js create mode 100644 package.json create mode 100644 readme.markdown create mode 100644 views/index.ejs create mode 100644 views/layout.ejs $ git remote add origin https://github.com/WEMP/project-slideshow.git $ git push -u origin master Username for 'https://github.com':
What am I doing wrong? This has never happened to me before but I recently also upgraded to git 22.214.171.124.
- Contributing to an existing pull request
- GIT: How can I do a pull request when I've already commited to my master branch?
- how to view the committed files those you have not pushed yet
- git stuck during push operation
- Is there a way to give a GitHub team privilege to read and write only to a private fork?
- Hg-Git and the Current Version (2) of Mercurial?
9 Solutions collect form web for “Why is Github asking for username/password when following the instructions on screen and pushing a new repo?”
Don’t use HTTP use SSH instead
you can do it in
I had this same issue and wondered why it didn’t happen with a bitbucket repo that was cloned with https. Looking into it a bit I found that the config for the BB repo had a URL that included my username. So I manually edited the config for my GH repo like so and voila, no more username prompt. I’m on Windows.
.git folder is hidden)
Save the file. Do a
git pull to test it.
The proper way to do this is probably by using git bash commands to edit the setting, but editing the file directly didn’t seem to be a problem.
Here is an official answer to this:
If Git prompts you for a username and password every time you try to interact with GitHub, you’re probably using the HTTPS clone URL for your repository.
Using an HTTPS remote URL has some advantages: it’s easier to set up than SSH, and usually works through strict firewalls and proxies. However, it also prompts you to enter your GitHub credentials every time you pull or push a repository.
You can configure Git to store your password for you. If you’d like to set that up, read all about setting up password caching.
an additional note:
if you have already added a remote ($git remote add origin … ) and need to change that particular remote then do a remote remove first ($ git remote rm origin), before re-adding the new and improved repo URL (where “origin” was the name for the remote repo).
so to use the original example :
$ git remote add origin https://github.com/WEMP/project-slideshow.git $ git remote rm origin $ git remote add origin https://email@example.com/WEMP/project-slideshow.git
I’ve just had an email from a github.com admin stating the following: “We normally advise people to use the HTTPS URL unless they have a specific reason to be using the SSH protocol. HTTPS is secure and easier to set up, so we default to that when a new repository is created.”
The password prompt does indeed accept the normal github.com login details. A tutorial on how to set up password caching can be found at https://help.github.com/articles/set-up-git#password-caching . I followed the steps in the tutorial, and it worked for me.
Because you are using HTTPS way.HTTPS requires that you type your account access every time you try to push or pull,but there is one way too, called SSH, and it lets you to tell git, that I give you permission with my account for this pc, and never ask me again about any user access. To use it, you have to generate SSH key and add it into your Github’s account just one time.To do that, you can follow these steps
How To Generate SSH key for Github
Improving upon @Ianl’s answer,
If you want to disable the prompts for both the username and password then you can set the URL as follows –
git remote set-url origin https://username:firstname.lastname@example.org/WEMP/project-slideshow.git
Note that the URL has both the username and password. Also the
.git/config file should show your current settings.
If you’re using HTTPS, check to make sure that your URL is correct. For example:
$ git clone https://github.com/wellle/targets.git Cloning into 'targets'... Username for 'https://github.com': ^C $ git clone https://github.com/wellle/targets.vim.git Cloning into 'targets.vim'... remote: Counting objects: 2182, done. remote: Total 2182 (delta 0), reused 0 (delta 0), pack-reused 2182 Receiving objects: 100% (2182/2182), 595.77 KiB | 0 bytes/s, done. Resolving deltas: 100% (1044/1044), done.
If you’ve enabled two factor authentication, then you’ll need to generate a personal access token and use that instead of your regular password. More info here: https://help.github.com/articles/creating-an-access-token-for-command-line-use/