DevOps/Git

[GitHub] ํŒŒ์ผ ์˜ฌ๋ฆฌ๋Š”๋ฐ ์—๋Ÿฌ {git@github.com: permission denied (publickey). fatal: could not read from remote repository},{ fatal: remote origin already exists.}

chaerlo127 2021. 12. 2. 01:33
728x90

GitHub์—

"์ ˆ์ฐจ์ ์‚ฌ๊ณ ์™€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ" ์ˆ˜๊ฐ•์‹ ์ฒญ ํ”„๋กœ๊ทธ๋žจ

์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ํŒŒ์ผ์„ GitHub์— ์—ฐ๋™ํ•˜๋ ค๊ณ ํ•˜๋Š”๋ฐ ์ด์™€ ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค.

 

1. 

git@github.com: permission denied (publickey). 
fatal: could not read from remote repository

 

 

2. 

//git remote add origin https://github.com/**/**.git ๋ช…๋ น์–ด ์‚ฌ์šฉ์‹œ
fatal: remote origin already exists.

 

 

์ด์™€ ๊ฐ™์€ ๋ฌธ์ œ์— ๋Œ€ํ•œ

ํ•ด๊ฒฐ์ฑ…์„ ์ ๊ณ ์žํ•œ๋‹ค.

 

 

1.  git@github.com: permission denied (publickey). fatal: could not read from remote repository

 

  • CMD ์ฐฝ์— ๋“ค์–ด๊ฐ€์„œ ์ด๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.
$ ssh-keygen -t rsa -C "Github ๊ณ„์ • ์ด๋ฉ”์ผ์ฃผ์†Œ"

 

๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ƒ์„ฑํ•˜๊ณ ์žํ•˜๋Š” ๋ฌธ๊ตฌ๊ฐ€ ๋œจ๋Š”๋ฐ, ๋‚˜๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ ์ƒ์„ฑ์ด ํ•„์š” ์—†์œผ๋‹ˆ

  • ๋ชจ๋‘๋‹ค ENTER๋ฅผ ์น˜๊ณ  ์ƒ๋žตํ•œ๋‹ค.

 

Window OS ๋‚ด๋ถ€์—  C:\Users\[์‚ฌ์šฉ์ž]/.ssh/id_rsa SSH ํŒŒ์ผ์ด ์ƒ์„ฑ๋˜์—ˆ์Œ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

 

  • GitHub์— Setting -> SSH and GPG keys ๋ฉ”๋‰ด๋กœ ์ด๋™

 

  • New SSH key Click

 

Key ๋ถ€๋ถ„์— C:\Users\[์‚ฌ์šฉ์ž]/.ssh/id_rsa SSH ํŒŒ์ผ์—์„œ

์ƒ์„ฑํ•œ id_rsa.pub ๋‚ด๋ถ€ ๋‚ด์šฉ์„ ๋ณต์‚ฌํ•˜์—ฌ KEY ๋ถ€๋ถ„์— ๋ถ™์—ฌ๋„ฃ๊ธฐ

  • ํ•ด๊ฒฐ ์™„๋ฃŒ
728x90

2. fatal: remote origin already exists.

 

์ด ์—๋Ÿฌ๋ฌธ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•จ

$ git remote rm origin

//๋‹ค์‹œ ๋ช…๋ น์–ด ์ž…๋ ฅ

$ git remote add origin https://github.com/**/**.git


$ git push -u origin main

 

  • ํ•ด๊ฒฐ ์™„๋ฃŒ 

 

<์ถœ์ฒ˜>

https://maliceit.tistory.com/51

https://jjunii486.tistory.com/153

728x90