Today I face an issue when I was trying to push my recent changes on my GITHUB directory. I was getting an access authentication error even my details were correct.

Then a bit searching a got to know that I am getting this error because of 2FA(two-factor authentication) is enabled in my account which I enabled a few days ago.
Basically, 2FA provides an extra layer of security used when logging into the account. For more details please refer to the GITHUB TWO FACTOR AUTHENTICATION
2FA requires user access token instead of the user password while running pull and push operation in GITHUB.
- Without 2FA
- $ git clone https://github.com/ashish-webkul/webkul-repo.git
- Username: your_username
- Password: your_password
- $ git clone https://github.com/ashish-webkul/webkul-repo.git
- With 2FA
- $ git clone https://github.com/ashish-webkul/webkul-repo.git
- Username: your_username
- Password: your_access_token
- $ git clone https://github.com/ashish-webkul/webkul-repo.git
Then first we need to know how to set up access token key on GITHUB account for the command line. Steps are given below,
- First of all, make sure your email-id should be verified. If not then verify first.
- Then go to the top right corner of your GITHUB account. Where you will see your profile picture. Click on that picture and then click on setting.

Then on the left side menubar, you will see Developer Setting“. Click on it and then click on “Personal access tokens”


Then you will see a button “Generate new token“. Click on that button to generate an access token,

Then after giving the access token name select the permission which you would like to give for that token.


After that click on “Generate Token“. Then you token will appear on the window.

This is how you can create an access token.
NOTE: Keep your access token secret
Now you can use access token as your authentication password for GITHUB pull & push operations.
We would love the hear your thoughts, suggestions, and questions in the comments below !!
PS E:\saylani mass it> git config user.name
MuhammadShoaib23
PS E:\saylani mass it> git commit -m “class 6 learning git and github”
On branch main
Initial commit
(use “git add …” to include in what will be committed)
Root/
class 2/
class 3/
class 5/
class 6/
nothing added to commit but untracked files present (use “git add” to track)
PS E:\saylani mass it> git add
Nothing specified, nothing added.
hint: Maybe you wanted to say ‘git add .’?
hint: Turn this message off by running
hint: “git config advice.addEmptyPathspec false”
PS E:\saylani mass it> git add .
error: ‘class 6/’ does not have a commit checked out
fatal: adding files failed
PS E:\saylani mass it> git commit -m “first commit”
On branch main
Initial commit
Untracked files:
(use “git add …” to include in what will be committed)
class 2/
class 3/
class 4/
class 5/
class 6/
nothing added to commit but untracked files present (use “git add” to track)
error: ‘class 6/’ does not have a commit checked out
fatal: adding files failed
At line:1 char:9
+ git add .
+ ~
The ‘