'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

enter image description here



Solution 1:[1]

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


Solution 2:[2]

Tried both the 1st and 2nd methods. Unsuccessful. However, after reinstalling, I restarted the computer and after starting, Git installed some restore/addition. After that, a pop-up window appeared - I passed the verification and everything worked out. After that, this letter came via e-mail:

A first-party GitHub OAuth application (Git Credential Manager) with gist, repo, and workflow scopes was recently authorized to access your account. Visit https://github.com/settings/connections/applications/0120e057bd645470c1ed for more information.

In the end, I achieved my goal. Then it should be easier.

Solution 3:[3]

I believe there is a bug in the latest version (2.32) try to downgrade git to this version (2.30.x) this is the link to download git 2.30.2

Solution 4:[4]

If you are using windows credential manager, use CMD instead of git bash. Then it gives you the alternative authentication methods to proceed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 AJM
Solution 3 karbi
Solution 4 Kelum Sampath Edirisinghe