Reputation: 519
I am using nano git bash terminal for windows and I haven't ever typed my password or anything like that in that terminal. All I typed was my email which I use on github and my full name. However, I am somehow able to push my commits to a repository on my github account via terminal. I asked some people about that and they all said that I can't push anything to a repository on github without having access to it, so I must be autheticated. But I've never typed my password, how can I be authenticated?
All I can see using git config --list are my email adress and name I typed earlier, without typing any password and stuff.
My question is, how can I see if I am authenticated or how do I authenticate with github via terminal? How do I see all my authentication settings and stuff?
UPD: And also I had git for windows with gui which I deinstalled later, but in which I had logged in github. Maybe that's why?
Upvotes: 5
Views: 2046
Reputation: 5329
You can authenticate and authorize GIT to access a Github repository with GIT Credentials Manager by running EITHER
$ git config credential.helper store
OR
$ git config --global credential.helper store
Then, the next time you push or pull, GIT may ask you how you want to authenticate:
Select an authentication method for 'https://github.com/':
1. Web browser (default)
2. Personal access token
option (enter for default):
If you choose (1), then a browser window will open, where you may be asked to log in to Github (if you aren't already), and eventually an OAuth access token will be created and stored locally on your machine, which will be used for all subsequent push/pull calls. You can revoke access by logging in to Github and going to Settings --> Applications --> OAuth Applications, where "GIT Credentials Manager" will be listed.
If you choose (2), then you first have to create a personal access token in the Github developer settings, and GIT will probably ask you to enter it. You can choose this approach if, for some reason, you cannot log in interactively using a browser, for example on a build server, on a system that doesn't have a modern browser, etc.
Note that this is how it works today. Github may change their authentication process, and it may have been different when the question was asked.
More in-depth information can also be found here.
Upvotes: 2