Categories
Software Development Web Development

How to fix Github git keeps asking for password with ssh keys

This was a super annoying issue I have had for years. I never looked into it because I was lazy.

I setup my ssh keys like you probably did and I kept getting prompted for my password.

I kept entering it for years because the github docs are not that great and fail to mention how to fully setup the keys properly(maybe changed by now). I kept wondering why it was asking me to enter my password even with the ssh keys.

Well a few days ago August 13th 2021, github switched from allowing password ssh git push/pull to not allowing it and forcing you to use something like ssh keys. I went to push to my github repo and was told I had to use ssh keys blah blah…

I was like

spock WTF
Wait. WTF?

I thought I had setup the ssh-keys. But, what had happened was I had used the HTTPS method to pull the repo. So my git config was set to the HTTPS endpoint not the SSH endpoint. It had been a long time ago. I thought I had setup the keys, and I did. What I failed to do was switch the git remote value in the git config.

are you kidding me
Freaking seriously

Basically if you pulled a repo via https then you need to switch your git configuration to use the ssh url. I won’t make this article longer writing how to do that, here is a great, short article that explains it

You also need to know the ssh repo value which you can find in the repository under clone like this

github clone
remote repo name

I have not tried the newer GitHub CLI. I will eventually read about it and try it and update my repos to use it. I did write about using github ssh deploy keys here though.  And about using multiple deploy ssh keys here.

Categories
Random Resources Software Development

How to push an existing project to a Github repository

While trying to figure out how to do this I found lots of bad info, info that lead to nothing but issues and bugs. I have stay so busy and do so many things I can never remember how to do anything. That is basically why this ENTIRE blog exists, my shit memory.

I found this article on DigitalOcean that works properly.

Step 1 create a repository on Github, even if the code you want to put in a repo exists, as long as it is not currently in any repo at all.

Step 2 navigate to the folder that contains the code that you want to push to the new Git/Github repo and run git init

Step 3 add the files with git add -A or git add .

Step 4 commit the files

Step 5 add the remote git origin server

Step 6 push to the remote git origin server

Or just use this script.

 

Categories
Resources Software Development

GIT how to check user settings

With git you can configure global or per repository settings. Global means any repository on your computer that you want to use will use these settings unless you specify specific settings per repository.

The settings I am speaking of are your username, email and remote origin etc.  This article at this link covers the basics of setting your email and username.

But how do you see what the current values of a repository are? Navigate to the repository, to the level where your .git directory is and type the following:
git config –list

You should see something like the following:

git configs example
example git configs output

You can also view individual settings such as user.name or user.email with the following
git config user.name

git config user.email

Those commands will output the current values that are set. Basically you are telling git to echo/print the current values.
Here is a list of all of the values you can set in the git configuration.

Here is a link to the documentation that explains how to get and set git configuration values.

The documentation links show mostly how to set global settings for git, many times you will want per repository settings such as the origin. This article covers nicely how to set per repository settings.

Bitbucket has created this really nice git tutorial and documentation.

Here is another page of links and resources about GIT

Categories
Resources Software Development Web Development

GIT resources and links

Articles

Semantic versioning with Git tags 

.gitignore file what is it, where to put it etc.

Git documentation

Git configuration documentation

Videos

Introduction to Git – Core Concepts

referenced in video – Pro Git 
Visual Git Reference by Mark Lodato


Introduction to Git – Branching and Merging


Introduction to Git – Remotes