Make sure there is at least one file in it (even just the README.md)
ssh-keygen -t ed25519 -C "your_email@example.com"
Note: If you are using a legacy system that doesn't support the Ed25519 algorithm, use:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
macOS:
pbcopy < ~/.ssh/id_rsa.pub
GNU/Linux (requires the xclip package):
xclip -sel clip < ~/.ssh/id_rsa.pub
Windows Command Line:
type %userprofile%\.ssh\id_rsa.pub | clip
Git Bash on Windows / Windows PowerShell:
cat ~/.ssh/id_rsa.pub | clip
or ofcourse copy it via your favorite editor, cat, or whatever suits your needs :)
Copy the contents of the to your SSH keys to your GitHub account settings (https://github.com/settings/keys).
ssh -T git@github.com
Change directory into the local clone of your repository (if you're not already there) and run:
To add remote:
git remote add origin git@github.com:username/your-repository.git
To change remote:
git remote set-url origin git@github.com:username/your-repository.git
Now try editing a file (try the README) and then do:
git add -A
git commit -am "Update README.md"
git push
You should not be asked for a username or password. If it works, your SSH key is correctly configured.