[github] Fix "Permission denied (publickey)" error when pushing with Git
어젯밤부터 계속 publickey 문제로 갑자기 git push가 안된다고 나와서 몇시간이나 고생을 했는데, 역시 안될 땐 그냥 덮어두고 다음날 새로 시작하는 기분으로 집중해서 찾아보니까 고쳐졌네요 휴. 쓰던 repository 그냥 삭제하고 새로 만들까 고민했는데, 고쳐져서 너무 다행입니다 😭
저는 아래의 글들 도움되었어요.
1. 로컬 머신에 SSH key 만들고 깃헙에 추가하는 법
https://gist.github.com/adamjohnson/5682757
Fix "Permission denied (publickey)" error when pushing with Git
Fix "Permission denied (publickey)" error when pushing with Git - publickey-git-error.markdown
gist.github.com
2. 로컬 머신에 SSH key 만들고 깃헙에 추가하는 법 (1과 같은 내용이지만 깃헙에서 어디에 추가하면 되는지 자세히 나와있어요!)
https://jhooq.com/github-permission-denied-publickey/
How to fix - git@github.com permission denied (publickey). fatal could not read from remote repository and Support for password
git@github.com: Permission denied (public key).fatal: Could not read from remote repository. - It means GitHub is rejecting your connection because - It is your private repo GitHub does not trust your computer because it does not have the public key of you
jhooq.com
3. 현재 branch가 protected 되어있어서 git push --force 가 안될 때
https://docs.gitlab.com/ee/user/project/protected_branches.html
Protected branches | GitLab
Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.
docs.gitlab.com
이거 참고하면서 저는 해당 repository의 settings로 들어가서 잠시 Allow force pushes를 허용하고 휘리릭 git push --force 하니까 해결되었습니다.

