Infra/Git

[Git] Git์— Repository ์ƒ์„ฑํ•˜๊ณ  ํ”„๋กœ์ ํŠธ ์˜ฌ๋ฆฌ๊ธฐ

carsumin 2024. 10. 30. 22:34
Git
  • ๊นƒ์€ ๋ถ„์‚ฐ ๋ฒ„์ „ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์œผ๋กœ ์†Œ์Šค์ฝ”๋“œ ํ˜•์ƒ๊ด€๋ฆฌ๋ฅผ ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋œ๋‹ค.
  • Git์„ ์‚ฌ์šฉํ•˜๋ฉด ์—ฌ๋Ÿฌ๋ช…์ด ํ˜‘์—…์ด ์šฉ์ดํ•˜๋ฉฐ ๋ฐ”๋€ ์ฝ”๋“œ๋ฅผ ํšจ๊ณผ์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค.

 

Git์— ํ”„๋กœ์ ํŠธ ์˜ฌ๋ฆฌ๊ธฐ

 

1.

GitHub์— ์ €์žฅ์†Œ ์ƒ์„ฑ
 
https://github.com/

GitHub ยท Build and ship software on a single, collaborative platform

Join the world's most widely adopted, AI-powered developer platform where millions of developers, businesses, and the largest open source community build software that advances humanity.

github.com

 
GitHub ๊ณ„์ •์ด ํ•„์š”ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํšŒ์›๊ฐ€์ž…์„ ๋จผ์ € ํ•ด์•ผํ•œ๋‹ค.
 

 
๋‚ด ํ”„๋กœํ•„์— ๋“ค์–ด๊ฐ€๋ฉด ์ƒ๋‹จ์— Repositories ๊ฐ€ ์žˆ๋‹ค.
Repositories > ์šฐ์ธก ์ƒ๋‹จ New ํด๋ฆญํ•œ๋‹ค.
 

 

2.

Repository name (์ €์žฅ์†Œ ์ด๋ฆ„)์„ ์ž…๋ ฅํ•œ๋‹ค.
๊ทธ ๋ฐ–์— ์ €์žฅ์†Œ์˜ ๊ณต๊ฐœ์—ฌ๋ถ€, ๋ฆฌ๋“œ๋ฏธ ๋“ฑ ์˜ต์…˜์„ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋‹ค.
 

 
์ €์žฅ์†Œ ์ƒ์„ฑ์„ ๋ˆ„๋ฅด๋ฉด ์œ„์™€ ๊ฐ™์€ ํ™”๋ฉด์ด ๋‚˜์˜ค๋Š”๋ฐ ์ €์žฅ์†Œ ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ•ด๋†“๋Š”๋‹ค.
ํ”„๋กœ์ ํŠธ์™€ Git์„ ์—ฐ๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•˜๋‹ค.
 

3. 

ํ”„๋กœ์ ํŠธ๊ฐ€ ์žˆ๋Š” ๊ฒฝ๋กœ๋กœ ๊ฐ€์„œ ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

$ git init
$ git remote add origin (GitHub ์ฃผ์†Œ)

 
๊ทธ ๋‹ค์Œ์— git status ๋ช…๋ น์–ด๋ฅผ ์ณ๋ณด๋ฉด git์ด ์ œ๋Œ€๋กœ ์—ฐ๊ฒฐ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
 

4.

$ git add (commitํ•  ํŒŒ์ผ๋ช…)

 
git add ๋ช…๋ น์–ด๋กœ commitํ•  ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•œ๋‹ค.
git add . ์„ ์ด์šฉํ•˜๋ฉด ๋ชจ๋“  ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ ์„ค์ •ํŒŒ์ผ ๋“ฑ ๋ชจ๋“  ํŒŒ์ผ์ด ๋‹ค ์˜ฌ๋ผ๊ฐ„๋‹ค๋Š” ์ ์„ ์ฐธ๊ณ ํ•œ๋‹ค.
 

5.

$ git commit -m "initial commit"

 
commitํ•  ํŒŒ์ผ์„ ๋ชจ๋‘ ์˜ฌ๋ ธ์œผ๋ฉด git commit ๋ช…๋ น์–ด๋กœ ์ปค๋ฐ‹๋ฉ”์‹œ์ง€์™€ ํ•จ๊ป˜ ํŒŒ์ผ๋“ค์„ ์ปค๋ฐ‹ํ•œ๋‹ค.
 

6.

$ git push origin master

 
master ๋ธŒ๋žœ์น˜์— commitํ•œ ์†Œ์Šค๋ฅผ push ํ•œ๋‹ค.
 
 

7.

Github์— ๋“ค์–ด๊ฐ€์„œ ์ฒ˜์Œ์— ๋งŒ๋“ค์—ˆ๋˜ ์ €์žฅ์†Œ์— ๊ฐ€๋ฉด ์†Œ์Šค๋“ค์ด ์ œ๋Œ€๋กœ ์—…๋กœ๋“œ ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.