Story
I have just finished a feature by the end of my work day, and am ready to push my pretty codes to the repo and about to enjoy an accomplished moment ๐...
BUT out of no where, after I run git push origin feature/my-awesome-code
,
my Bash shell yells at me with this ๐คฏ:
This gets me thinking and checking my SSH key and stuffs... all are correct!
What on earth is wrong!!! ๐ต
And who cares about Git GUI, because pros only use Git command here. ๐
After, and after some tiring searches, I finally found the root cause of this problem.
Root Cause
The root cause is that Bash shell does not know my HOME
Normally, in Bash shell if you run cd ~
, it will goes to your home directory (e.g. C:\users\username
) where you stored your SSH key, instead it shows this weird /y
drive which I don't remember existed in my computer.
and obviously, you list files in this /y
, you got nothing, that's why it shows above error permission denied (publicKey)
, simply means the public key is not found there.
Solution
To solve it, you need to set environment variable HOME
to let your Bash shell aware.
Window search for "Edit the system environment variables", will lead you to this dialog
Set
HOME
to your home directory where SSH key is stored.OK, Apply, OK...
Restart your bash shell for it to take effect
You've done, you've solved it! ๐
Extra Catches
If it still does not work for you,
- try to restart your computer after setting the environment variable (very most likely no need to do so, but just do otherwise ๐)
- Bash shell already got the public key, but you yourself miss configuring it in your remote repository, etc... ๐