git push error “remote: Invalid username or password. fatal: Authentication failed”

I have 2-factor authentication enabled on my account. The repo is my own and I was unable to push changes to a private branch.

Steps to resolve

1. Check your remote of repo

$ git remote -v
origin https://github.com/vishalkanaujia/gnome-connection-manager-1.git (fetch)
origin https://github.com/vishalkanaujia/gnome-connection-manager-1.git (push)

Looked carefully, I was trying to push using https.

2. I updated local system’s SSH keys to my github account.

3. Next, I changed the remote to SSH.

# Remove original origin
$ git remote remove origin 

# Added SSH origin
$ git remote add origin git@github.com:vishalkanaujia/gnome-connection-manager-1.git

#Pushed changes
$ git push origin fix_shortcuts
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 536 bytes | 536.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote: 
remote: Create a pull request for 'fix_shortcuts' on GitHub by visiting:
remote: https://github.com/vishalkanaujia/gnome-connection-manager-1/pull/new/fix_shortcuts
remote: 
To github.com:vishalkanaujia/gnome-connection-manager-1.git
* [new branch] fix_shortcuts -> fix_shortcuts
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.