๐Ÿค ์€์ง€log ๐Ÿค

[Git] ๊นƒ๋žฉ(GitLab) ์‚ฌ์šฉํ•˜๊ธฐ ๋ณธ๋ฌธ

๐Ÿฅ TIP

[Git] ๊นƒ๋žฉ(GitLab) ์‚ฌ์šฉํ•˜๊ธฐ

Eun_zii 2023. 3. 24. 15:16

๊ฐœ์ธ์ ์œผ๋กœ๋Š” GitHub , ์‚ฌ์ด๋“œํ”„๋กœ์ ํŠธ ์—์„œ๋Š” Gitea,

ํšŒ์‚ฌ์—์„œ๋Š” GitLab์„ ์‚ฌ์šฉ์ค‘์ด๋‹ค. ...๐Ÿซ 

 

๐ŸŠ GitLab ์ด๋ž€

๊ฐœ์ธ ๋˜๋Š” ์กฐ์ง์ด Git ๋ ˆํฌ์ง€ํ† ๋ฆฌ์˜ ๋‚ด๋ถ€ ๊ด€๋ฆฌ๋ฅผ ์ œ๊ณตํ•˜๋Š” ๋ฐ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” Github๋กœ, 

๋น„๊ณต๊ฐœ๋œ Github ์ด๋‹ค.

 

๐ŸŠ GitLab ์‚ฌ์šฉ์ด์œ  

๊นƒ๋žฉ์€ ์ค‘์•™ ์„œ๋ฒ„์—์„œ git ์ €์žฅ์†Œ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.

๋ ˆํฌ์ง€ํ† ๋ฆฌ ๋˜๋Š” ํ”„๋กœ์ ํŠธ๋ฅผ ์™„๋ฒฝํ•˜๊ฒŒ ์ œ์–ดํ• ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๊ณต๊ฐœ ๋˜๋Š” ๋น„๊ณต๊ฐœ ์—ฌ๋ถ€๋ฅผ ๋ฌด๋ฃŒ๋กœ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

์‹ค๋ฌด์—์„  gitLab ์‚ฌ์šฉ์ด ํ›จ์”ฌ ๋งŽ๋‹ค.

 

 

๐Ÿ“ GitLab (Clone,Checkout, Commit, Push ) ๐Ÿ“

1. ์†Œ์Šค ์ฝ”๋“œ Clone ํ•˜๊ธฐ with HTTPS

 

์†Œ์Šค์ฝ”๋“œ๊ฐ€ ๋“ค์–ด์žˆ๋Š” ๋ ˆํฌ์ง€ํ† ๋ฆฌ์—์„œ

Clone -> Clone with HTTPS -> ๋ณต์‚ฌํ•œ๋‹ค.

$ git clone https://gitlab.com/ [๋ ˆํฌ์ง€ํ† ๋ฆฌ์ด๋ฆ„].git

๋ช…๋ น์–ด ์ž…๋ ฅํ›„ , gitlab์˜ ์‚ฌ์šฉ์ž ๊ณ„์ • ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

ํด๋”๋‹จ์œ„๋กœ ๋‚ด๋ ค๋ฐ›์•„์ง„๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

2. ์†Œ์Šค ์ฝ”๋“œ Clone ํ•˜๊ธฐ with SSH

 

์†Œ์Šค์ฝ”๋“œ๊ฐ€ ๋“ค์–ด์žˆ๋Š” ๋ ˆํฌ์ง€ํ† ๋ฆฌ์—์„œ

Clone -> Clone with SSH -> ๋ณต์‚ฌํ•œ๋‹ค.

$ git@gitlab.com:[๋ ˆํฌ์ง€ํ† ๋ฆฌ์ด๋ฆ„].git

๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด , permission denied (public key) ์—๋Ÿฌ๊ฐ€ ๋‚œ๋‹ค.

ํ•ด๋‹น pc์˜ ssh ์ธ์ฆ์— ํ•„์š”ํ•œ key๊ฐ€ gitlab์— ๋“ฑ๋ก๋˜์–ด ์žˆ์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

 

2-1. SSH-Key ์„ค์ •ํ•˜๊ธฐ

ํ„ฐ๋ฏธ๋„์„ ํ‚ค๊ณ  $ ssh-keygen ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

Enter file in which to save the key (/Users/eun_ji/.ssh/id_rsa): // ์—”ํ„ฐ
Enter passphrase (empty for no passphrase): // ์—”ํ„ฐ
Enter same passphrase again: // ์—”ํ„ฐ

 

๊ฐœ๋ฐœ ํ™˜๊ฒฝ ํ™ˆ ๋””๋ ‰ํ† ๋ฆฌ์— .ssh ํด๋”๋กœ ์ด๋™ํ›„ id_rsa.pub ํŒŒ์ผ์„ ํ™•์ธํ•œ๋‹ค.

$ cat id_rsa.pub

 

 

๊ทธ๋Ÿฌ๋ฉด ์ด๋ ‡๊ฒŒ key๊ฐ€ ๋‚˜์˜ค๊ณ  ์ „์ฒด ๋ณต์‚ฌํ›„ 

GitLab์œผ๋กœ ์ด๋™ํ•œ๋‹ค.

 

3. GitLab์— SSH key ๋“ฑ๋กํ•˜๊ธฐ

 

GitLab ์˜ค๋ฅธ์ชฝ ์ƒ๋‹จ ํ”„๋กœํ•„ ์‚ฌ์ง„ ํด๋ฆญ ํ›„, Preferences ๋กœ ๋“ค์–ด๊ฐ„๋‹ค. 

 

์™ผ์ชฝ ๋ฉ”๋‰ด์— SSH Keys ๋กœ ๋“ค์–ด๊ฐ€๋ฉด Key ์นธ์— ์•„๊นŒ ๋ณต์‚ฌํ•œ is_rsa.pub(ssh-key)์„ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•ด์ค€๋‹ค.

 

์ •์ƒ์ ์œผ๋กœ SSH Key๊ฐ€ ์ž…๋ ฅ์ด ๋˜๋ฉด ์ƒ์„ธ ๋‚ด์šฉ์„ ํ™•์ธํ• ์ˆ˜ ์žˆ๋‹ค. 

 

์œ„ ๊ณผ์ •์„ ๋งˆ์น˜๊ณ  ๋‹ค์‹œ 2. ์†Œ์Šค ์ฝ”๋“œ Clone ํ•˜๊ธฐ with SSH ์„ ์ง„ํ–‰ํ•˜๋ฉด ์ •์ƒ์ ์œผ๋กœ ์ง„ํ–‰๋œ๋‹ค.

 

4. Branch ๋ณ€๊ฒฝํ•˜๊ธฐ

์ฒ˜์Œ clone ํ•˜๊ฒŒ ๋˜๋ฉด master ๋ธŒ๋žœ์น˜์— ์œ„์น˜ํ•˜๊ฒŒ ๋œ๋‹ค.

๊ฐœ์ธ ์ €์žฅ์†Œ๋ผ๋ฉด ์ƒ๊ด€์—†๊ฒ ์ง€๋งŒ ๊ณต์œ ์šฉ ์ €์žฅ์†Œ๋ผ๋ฉด ๋ธŒ๋žœ์น˜๋ฅผ ๊ฐ์ž ์ƒ์„ฑํ•˜์—ฌ ์ปค๋ฐ‹ํ›„ ๋ณ‘ํ•ฉํ•˜๋Š”๊ฒƒ์ด ์ข‹์„๊ฒƒ ๊ฐ™๋‹ค.

$ git checkout -b [๋ธŒ๋žœ์น˜ ์ด๋ฆ„]

 

์œ„ ๋ช…๋ น์–ด๋กœ ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ ๊ณผ ์ „ํ™˜์„ ํ•ด์ค€ํ›„ 

$ git branch

 

์œ„ ๋ช…๋ น์–ด ์ž…๋ ฅํ•˜๊ณ  ํ˜„์žฌ ๋ฐ”๋ผ๋ณด๊ณ  ์žˆ๋Š” ๋ธŒ๋žœ์น˜๋ฅผ ํ™•์ธํ•œ๋‹ค. : ์ž์‹ ์ด ์ƒ์„ฑํ•œ ๋ธŒ๋žœ์น˜๋ฅผ ๋ฐ”๋ผ๋ณด๊ณ  ์žˆ์œผ๋ฉด ๋จ

5. Commit ํ•˜๊ธฐ

$ git add . // ์ˆ˜์ • ์‚ฌํ•ญ๋“ค์„ ์ „๋ถ€ ์ถ”๊ฐ€ํ•จ : add ๋’ค์— . ์„ ๋”ํ•ด์ฃผ๋ฉด ์ „๋ถ€ ํ•˜๊ฒ ๋‹ค๋Š” ์˜๋ฏธ์ด๋‹ค.

$ git commit -m "commit comments" 
// commit comments ์—๋Š” ์ปค๋ฐ‹ ์ปจ๋ฒค์…˜์ด ์žˆ๋‹ค๋ฉด ์ฐธ๊ณ ํ•ด์„œ ์ž‘์„ฑํ•œ๋‹ค.

 

6. Push ํ•˜๊ธฐ

push ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ git ์›๊ฒฉ ์ €์žฅ์†Œ์— ์ €์žฅํ•œ๋‹ค.

$ git push

 

gitLab์— ์ ‘์†ํ•˜์—ฌ ์ปค๋ฐ‹๋œ๊ฒƒ์„ ํ™•-์ธ !

728x90