After $git push -u origin main command, Git bash is not requesting any authentication literally does nothing
When I am trying to upload my code to github. Below are the steps which I executed in the Git Bash terminal. When I try to push the code to github using $ git push -u origin main
the cursor moves to the next line and keeps blinking but does nothing.
git remote add origin "https://github.com/TarunRajinikanth/Trifacta.git"
git add -A
git config --global -user.name "username"
git config --global -user.email "[email protected]"
git commit -m "this is my first commit"
git branch -m main
git push -u origin main
Solution 1:
Update Oct. 2021:
issue 384 describes again the problem:
During the host provider auto-detection when GCM makes a HTTP call to the remote, this can sometimes hang until a long timeout period has elapsed.
This now has been fixed with PR 481 "Speed up host provider auto-detection and make more robust" (see commit 1f926e4)
Update July 2021:
Git for Windows 2.32.0(2) does include GCM (Git Credential Manager Core) v2.0.475.64295, which should solve the issue/PR 374 ("Fix bug where GUI prompts would not be shown on Windows").
Original answer (June 2021):
Check your git config credential.helper
to see if a caching mechanism would be the issue.
You should:
- double-check our
%PATH%
(before opening a git bash), in order to referenceC:\Program Files\Git\mingw64\libexec\git-core
, - double-check what is stored in the Windows Credential Manager
you do that with:
printf "host=github.com\nprotocol=https"|git-credential-manager get
If you see the wrong password, remove it with:
printf "host=github.com\nprotocol=https"|git-credential-manager erase
Repeat the erase
command until you see a popup (do not enter your credentials then)
Then repeat your git push -u origin main
, and enter your credentials to store them.
Note that git-for-windows/git issue 3268 points to microsoft/Git-Credential-Manager-Core
issue 364.
As a temporary workaround:
git config --global credential.provider generic
Note that microsoft/Git-Credential-Manager-Core
v2.0.475 has just been released to fix issue 364 with PR 375, in the context of Git 2.32 (May 2021).
The latest snapshot of Git for Windows should include that fix.
Solution 2:
I too had the same problem, I managed to solve it after hours of work. Now I share with you how I managed it 🙂. I found three methods to solve this problem, I hope at least one of them works for you! But before I explain the solution that worked for me, I'll explain step by step what the problem is:
IF EVERYTHING WORKED:
If everything worked (as it should), after running the command:$ git push -u origin main
a new small window would appear for entering the GitHub username and password, this is because basically Git asks GitHub for permission to make changes.
This "window" is the Credential Helper.
CAUSE OF THE PROBLEM:
So the problem you're experiencing is due to an authentication issue.
SOLUTIONS:
-
1. First Method
This problem often occurs when you install Git: we all tend to click on the "next" button to leave the default settings unchanged, without paying much attention to what is being asked of us. During Git installation, in fact, we are asked to choose the "Credential Helper"! During the installation of the latest version of Git, there is a default setting that didn't work for me at all. So I'm inclined to think that those who install the new version of Git may run into this problem (probably for Windows users).
So what to do?
Uninstall Git: I know it's a hassle because you have to reconfigure everything but if you want to avoid uninstalling Git then I suggest you skip this method.
So I repeat, uninstall Git. When you reinstall it, be especially careful when it asks you to choose the Credential Helper. Change the default setting, choose "Git Credential Manager", as you can see from the picture:Â click here to see the photo
(in fact, if you notice, it says that it handles credentials for GitHub)
Continue with the installation. Now your problem should not occur again. -
2. Second Method
To solve the problem, another method is to change the URL in this way:$ git config remote.origin.url https://USERNAME:[email protected]/USERNAME/REPONAME.git
In this way, you would not only solve the problem without the help of the Credential Helper, but you would also save your Github username and password on Git: this way you would no longer need to enter your username and password every time you need to save your code on Github. Now try push, the problem should be solved. -
3. Third Method (RECOMMENDED)
To solve this problem, you must create an SSH key pair. There is little you can do, you will have to do it sooner or later if you want to work in a team. An SSH key helps ensure a secure connection between your local repository and a secure remote repository.
This is also very useful because it saves you from having to identify yourself each time.
In Git Bash, run the following command to generate your SSH key pair:$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Now press the enter key twice on the keyboard.
Great, you've just created your SSH key pair.
To find it, just go to the address:
C:\Users\YourUsername\.ssh
and view the hidden folders.
You then have two files in this folder:
your public key: id_rsa.pub
your private key: id_rsa.txt
You can copy your public key by opening it in a notepad.
Now let's see how to add the key to your GitHub account.
Log in to your GitHub space, then go to the right corner of your account and click on Settings. Click on the "SSH and GPG keys". Click on "New SSH key".
Choose a title (for example 'personal key'), paste your SSH key and click on "Add SSH key".
The end.
Your SSH key has been added to your GitHub account, you now have permission to push your code to the platform from your computer.
PS: Before pushing your code, remember to use the correct url when using the SSH key: see notes below. -
Other methods??
There will probably be other methods to solve the same problem. If you're using windows, one of these might be to open the Credential Manager on Windows (search by typing this name into the search bar) and from there somehow enter your GitHub username and password. This is a way that I have not followed honestly, that I discovered late and I do not know if it works or not, I wanted to share it with you anyway.
I hope I have been of help to some of you. 🙂
NOTES FOR BEGINNERS
Remember:
-
1. When you use the SSH key pair, the url you need to use is NOT the following:
https://github.com/USERNAME/REPONAME.git
but it is the following:[email protected]:USERNAME/REPONAME.git
-
2. Before pushing your code, I remind you to add the url using the command:
$ git remote add origin [email protected]:USERNAME/REPONAME.git
or if you added the wrong one and want to change it then use the command:$ git config remote.origin.url [email protected]:USERNAME/REPONAME.git
-
3. the word origin is just a default name. You may associate a url with any word you wish to use:
$ git remote add WORD URL