hanbin.dev

git ๋กœ๊ทธ์ธ ์—†์ด ์‚ฌ์šฉํ•˜๊ธฐ ๋ณธ๋ฌธ

์นดํ…Œ๊ณ ๋ฆฌ ์—†์Œ

git ๋กœ๊ทธ์ธ ์—†์ด ์‚ฌ์šฉํ•˜๊ธฐ

hanbindev 2022. 5. 24. 02:17

๐Ÿ’ก pull, push ํ• ๋•Œ๋งˆ๋‹ค ๋กœ๊ทธ์ธํ•˜๊ธฐ ๋ฒˆ๊ฑฐ๋กญ๊ธฐ ๋•Œ๋ฌธ์—, ssh agent๋ฅผ ์„ค์ •ํ•ด๋‘์ž

ssh key ์ƒ์„ฑ

ssh-keygen -t rsa -b 4096 -C "๋ณธ์ธ gitlab email"
# id_rsa ์ด๋ฆ„ ์„ค์ • (id_gitlab)
# ์ดํ›„๋กœ ๋ญ๋ผ ๋‚˜์˜ค๋Š”๋ฐ ๋ฌด์‹œํ•˜๊ณ  ์—”ํ„ฐ

ssh agent ํ™œ์„ฑํ™”

eval "$(ssh-agent -s)"

ssh agent์— ssh key ๋“ฑ๋ก

ssh-add ~/.ssh/id_gitlab

remote branch ssh ํ”„๋กœํ† ์ฝœ๋กœ ์ง€์ •

# ๊ธฐ์กด remote ์‚ญ์ œ
git remote rm origin

# ssh ํ”„๋กœํ† ์ฝœ origin ์ƒ์„ฑ
git remote add origin ssh://git@git.elicer.io:2201/elice/backend/elice-api.git

Gitlab์— ssh key ๋“ฑ๋ก

cat ~/.ssh/id_gitlab
# ๊ฒฐ๊ณผ ๊ฐ’ ๋ณต์‚ฌ

์œ„์—์„œ ๋ณต์‚ฌํ•œ ๊ฒฐ๊ณผ ๊ฐ’ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ›„ Add Key

gitlab ssh keys setting