While working on lab assignments for Flatiron School I started noticing a surprise error message when pushing my assignments to GitHub:
cannot read username for GitHub. This post is describing my discoveries, a work around, and an eventual discovery as a postscript at the end.
NOTE: This is not a tutorial on how to set up GIT on your computer, but is a troubleshooting tutorial of my experiences.
So, when I start a new lab my workflow is pretty straight forward:
- Browse to the Learn-co(Flatiron's learning platform) Repo
- Fork the repository to my account.
- Clone the repository to my computer.
I currently use JetBrain products to develop, and there is a great browser plugin that adds clone links to my GitHub repositories, interacts with JetBrains Toolbox.
By click on the appropriate icon, I can open the project in Rubymine or Webstorm or any other Jetbrain application. This automatically clone the project and asks if I want to open the application. This has been my workflow.
- So, the first time the surprise error message appeared,
cannot read username for GitHub, I thought it might be my
SSHsetup, since I had recently upgraded my Linux OS. So, I checked:
ssh -T email@example.com
But it returned with a successful message.
- Then I thought it may have been the Learn gem which I use to push completed lessons back to the repo, but it authenticated just fine.
- Then the error happened again in a different repo not connected with
Learnand after some investigating I realized the issue was not associated with a
Learn. The problem but that I when cloning via the Jetbrains browser plugin, it was cloning via
DISCLAIMER: This solution works for my system. I have a single user system not connected to a work network, just a home office. Please investigate the best solution for you and your own security.
Per the GIT documentation: "Git will sometimes need credentials from the user in order to perform operations; for example, it may need to ask for a username and password in order to access a remote repository over HTTP."
- After reading the documentation, I decided to set up as Git Credentials Store.
- Setup global credentials helper:
git config --global credential.helper store
The first time you push to a
https repository, you will still need to enter your username and password, but after that it will be stored in the file you created in unencrypted text.
If you examine the
git-credentials file the site is saved in the following format: