Assuming you are connecting GitHub over SSH, you can run below command to confirm this.
$git config --get remote.origin.url
If you get a result has following format [email protected]:xxx/xxx.github.com.git, then you should do the following.
Generate a SSH key(or use existing one). if you had one, you just need to add your key to the ssh-agent (step 2)and to your GitHub account(step 3).
below are for those who don't have SSH key.
Step 1 Generating public/private rsa key pair.
$ssh-keygen -t rsa -b 4096 -C "[email protected]"
You'll be asked to confirm where to save the SSH key and what passphrase you want to use.
Step 2 Add your key to the ssh-agent
Step 3 Add your SSH key to your account
$sudo apt-get install xclip
$xclip -sel clip < ~/.ssh/id_rsa.pub
Then add the copied key to GitHub
Go to Settings->SSH keys(Personal settings side bar)->Add SSH key->fill out form(key is on your clipboard, just use ctrl+v)->Add key
After going through above steps, you should solve the permission problem.
Reference Link:
Generating SSH keys.
git push -u origin main
on Dec 27, 2021, and that's ok. But when it comes to Nov 21 2022, that output just the question. Then I just use this to fix the problem. Via "git pull --rebase && git push -u origin main". – Unwisdomssh -T git@sofija_personal-github.com
. OVER! – Unwisdom