ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

Git

[Git] Git์ด๋ž€?

๊ฐœ๋ฐœ๊ฐœ๊ตด๐Ÿธ 2022. 7. 3. 20:25

Git์ด๋ž€ ๋ฌด์—‡์ธ๊ฐ€?

Git์€ 2005๋…„์— ๋ฆฌ๋ˆ„์Šค ํ† ๋ฅด๋ฐœ์Šค์— ์˜ํ•ด ๊ฐœ๋ฐœ๋œ ๋ถ„์‚ฐ ๋ฒ„์ „๊ด€๋ฆฌ ์‹œ์Šคํ…œ(Distributed Version Control System - DVCS)๋กœ, ์ปดํ“จํ„ฐ ํŒŒ์ผ์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ถ”์ ํ•˜๊ณ  ์—ฌ๋Ÿฌ๋ช…์˜ ์‚ฌ์šฉ์ž๋“ค ๊ฐ„์— ํŒŒ์ผ์— ๋Œ€ํ•œ ์ž‘์—…์„ ์กฐ์œจํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. Git ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ๋งŒ๋“ค์–ด์ง„ ํ˜•์ƒ ๊ด€๋ฆฌ ๋„๊ตฌ์ค‘ ํ•˜๋‚˜ ์ž…๋‹ˆ๋‹ค.

 

์ฆ‰, ์—ฌ๋Ÿฌ๋ช…์˜ ๊ฐœ๋ฐœ์ž๊ฐ€ ํ•˜๋‚˜์˜ ์†Œํ”„ํŠธ์›จ์–ด ๊ฐœ๋ฐœ ํ”„๋กœ์ ํŠธ์— ์ฐธ์—ฌํ•  ๋•Œ, ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š”๋ฐ ํ•„์ˆ˜์ ์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

 

** ํ˜•์ƒ ๊ด€๋ฆฌ ๋„๊ตฌ (Configuration Management Tool)

๋Œ€ํ‘œ์ ์ธ ํ˜•์ƒ ๊ด€๋ฆฌ ๋„๊ตฌ(๋ฒ„์ „ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ)์€ SVN๊ณผ Git์ด ์กด์žฌํ•˜๋Š”๋ฐ, Git์€ ์ค‘์•™ ์„œ๋ฒ„๋งŒ ์‚ฌ์šฉํ•˜๋Š” SVN๊ณผ ๋‹ค๋ฅด๊ฒŒ ๋ถ„์‚ฐํ˜• ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์œผ๋กœ, ๋กœ์ปฌ ์ €์žฅ์†Œ์™€ ์ค‘์•™ ์ €์žฅ์†Œ๋ฅผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ํŠน์ง•์ž…๋‹ˆ๋‹ค.

 

Git์˜ ์žฅ์ 

  • ์†Œ์Šค ์ฝ”๋“œ์˜ ๋ณ€๊ฒฝ ์ด๋ ฅ์„ ์‰ฝ๊ฒŒ ํ™•์ธ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
  • ํŠน์ • ์‹œ์ ์— ์ €์žฅ๋œ ๋ฒ„์ „๊ณผ ๋น„๊ตํ•˜๊ฑฐ๋‚˜ ํŠน์ • ์‹œ์ ์œผ๋กœ ๋˜๋Œ์•„๊ฐˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ Git ์‹œ์Šคํ…œ์„ ์ด์šฉํ•˜๊ธฐ ์œ„ํ•ด ์ฝ”๋“œ๋ฅผ ์ €์žฅํ•˜๋Š” ์ €์žฅ์†Œ Repository๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ, Repository๋Š” ํฌ๊ฒŒ 2๊ฐ€์ง€๋กœ ๋‚˜๋‰ฉ๋‹ˆ๋‹ค.

๋ง๊ทธ๋Œ€๋กœ ํŒŒ์ผ์ด๋‚˜ ํด๋”๋ฅผ ์ €์žฅํ•ด๋‘๋Š” ๊ณณ์œผ๋กœ, Local ์ €์žฅ์†Œ์™€ Remote(์›๊ฒฉ)์ €์žฅ์†Œ 2๊ฐœ๋กœ ๋ถ„์‚ฐํ•˜์—ฌ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

  • Local Repository : ๋‚˜์˜ PC์— ์ €์žฅ๋˜๋Š” ๊ฐœ์ธ ์ „์šฉ ์ €์žฅ์†Œ
  • Remote Repository : ์›๊ฒฉ ์ €์žฅ์†Œ ์ „์šฉ ์„œ๋ฒ„์— ์ €์žฅ๋˜๋Š” ์ €์žฅ์†Œ

์ด๋Ÿฌํ•œ ์ €์žฅ์†Œ๋ฅผ ํ†ตํ•ด ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์ฃผ๊ณ  ๋ฐ›์„ ํ•„์š” ์—†์ด, ๊ฐ™์€ ํŒŒ์ผ์„ ์—ฌ๋Ÿฌ ๋ช…์ด ๋™์‹œ์— ์ž‘์—…ํ•˜๋Š” ๋ณ‘๋ ฌ ๊ฐœ๋ฐœ์ด ๊ฐ€๋Šฅํ•ด์ง‘๋‹ˆ๋‹ค.

์ฆ‰, ๋ธŒ๋žœ์น˜๋ฅผ ํ†ตํ•ด ๊ฐœ๋ฐœํ•œ ๋’ค, ๋ณธ ํ”„๋กœ๊ทธ๋žจ์— ํ•ฉ์น˜๋Š” Merge๋ฅผ ํ†ตํ•ด ๊ฐœ๋ฐœ์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

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

 

Git์˜ ๊ธฐ๋ณธ ์šฉ์–ด

์šฉ์–ด ์„ค๋ช…
Repository ์ €์žฅ์†Œ๋Š” ํžˆ์Šคํ† ๋ฆฌ, ํƒœ๊ทธ, ์†Œ์Šค์˜ ๊ฐ€์ง€์น˜๊ธฐ ํ˜น์€ Branch์— ๋”ฐ๋ผ ๋ฒ„์ „์„ ์ €์žฅ
Working Tree ์ €์žฅ์†Œ๋ฅผ ์–ด๋Š ํ•œ ์‹œ์ ์„ ๋ฐ”๋ผ๋ณด๋Š” ์ž‘์—…์ž์˜ ํ˜„์žฌ ์‹œ์ 
Staging Area ์ €์žฅ์†Œ์— ์ปค๋ฐ‹ํ•˜๊ธฐ ์ „์— ์ปค๋ฐ‹์„ ์ค€๋น„ํ•˜๋Š” ์œ„์น˜
Commit ํ˜„์žฌ ๋ณ€๊ฒฝ๋œ ์ž‘์—… ์ƒํƒœ๋ฅผ ์ ๊ฒ€์„ ๋งˆ์น˜๋ฉด ํ™•์ •ํ•˜๊ณ  ์ €์žฅ์†Œ์— ์ €์žฅํ•˜๋Š” ์ž‘์—…
Head ํ˜„์žฌ ์ž‘์—…์ค‘์ธ Branch๋ฅผ ๊ฐ€๋ฆฌํ‚ด
Branch ๊ฐ€์ง€ ๋˜๋Š” ๋ถ„๊ธฐ์ . ์ž‘์—…์„ ํ• ๋•Œ์— ํ˜„์žฌ ์ƒํƒœ๋ฅผ ๋ณต์‚ฌํ•˜์—ฌ Branch์—์„œ ์ž‘์—…์„ ํ•˜์—ฌ ์™„๋ฃŒ๋˜๋ฉด Merge๋ฅผ ํ†ตํ•ด ์ƒ์œ„์— ํ•ฉ์นจ
Merge ๋‹ค๋ฅธ Branch์˜ ๋‚ด์šฉ์„ ํ˜„์žฌ Branch๋กœ ๊ฐ€์ ธ์™€ ํ•ฉ์น˜๋Š” ์ž‘์—…

 

Git์˜ ๊ธฐ๋ณธ ๋ช…๋ น์–ด

๋ช…๋ น์–ด ์„ค๋ช…
git help ๋„์›€๋ง ๊ธฐ๋Šฅ. ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉํ•˜๋Š” 21๊ฐœ์˜ ๊นƒ ๋ช…๋ น์–ด ์ถœ๋ ฅ
git init ๊นƒ ์ €์žฅ์†Œ๋ฅผ ์ดˆ๊ธฐํ™”. ์ด ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๊นƒ ์ €์žฅ์†Œ๋ฅผ ์ƒ์„ฑ
git status ์ €์žฅ์†Œ ์ƒํƒœ ์ •๋ณด๋ฅผ ์ฒดํฌํ•˜๊ณ  ์ถœ๋ ฅ
git branch ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑ.
git add stating ์˜์—ญ์— ๋ณ€๊ฒฝ ๋‚ด์šฉ์„ ์ถ”๊ฐ€
git commit stating area์— ์žˆ๋Š” ๋ณ€๊ฒฝ ๋‚ด์šฉ ๋ฌถ์Œ ๋ฐ ์ •์˜
git log ์ปค๋ฐ‹ ๋‚ด์—ญ ํ™•์ธ
git push Local์ €์žฅ์†Œ์—์„œ ์„œ๋ฒ„๋กœ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ด๋™์‹œ์ผœ ์ €์žฅ
git pull ์„œ๋ฒ„ ์ €์žฅ์†Œ๋กœ๋ถ€ํ„ฐ ์ตœ์‹  ๋ฒ„์ „์„ ๋ฐ›์•„์˜ด
git clone ์„œ๋ฒ„ ์ €์žฅ์†Œ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋กœ์ปฌ๋กœ ๋ณต์‚ฌํ•ด ์ €์žฅ
git checkout ์ž‘์—…ํ•˜๊ธฐ ์›ํ•˜๋Š” ๋ธŒ๋žœ์น˜๋กœ ์ด๋™ํ•˜๋Š” ๋ช…๋ น์–ด
git merge branch์—์„œ ์ž‘์—…์„ ๋งˆ์นœ ํ›„ ๋‹ค๋ฅธ branch์™€ ๋‚ด์šฉ์„ ํ•ฉ์นจ

 

 

 

 

https://java-man.tistory.com/12

 

[Git] Git ์ด๋ž€? ์ •์˜ ๋ฐ ์šฉ์–ด ์ •๋ฆฌ

์•ˆ๋…•ํ•˜์„ธ์š”. ์˜ค๋Š˜์€ git์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Git์ด๋ž€, ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ๋งŒ๋“ค์–ด์ง„ "๋ถ„์‚ฐํ˜• ๋ฒ„์ „ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ" ์ž…๋‹ˆ๋‹ค. ์›๋ž˜๋Š” Linux ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๊ด€๋ฆฌํ•  ๋ชฉ์ ์œผ๋กœ ๋งŒ๋“ค์–ด

java-man.tistory.com

 

https://goddaehee.tistory.com/91

 

[์›น๊ฐœ๋ฐœ ๊ธฐ์ดˆ] Git ์ด๋ž€?

[์›น๊ฐœ๋ฐœ ๊ธฐ์ดˆ] Git ์ด๋ž€? ์•ˆ๋…•ํ•˜์„ธ์š”. ๊ฐ“๋Œ€ํฌ ์ž…๋‹ˆ๋‹ค. ์ด๋ฒˆ ํฌ์ŠคํŒ…์€ [Git ๊ธฐ์ดˆ] ์ž…๋‹ˆ๋‹ค. :) 1. Git์ด๋ž€? (์ฐธ๊ณ  : https://git-scm.com/book/ko/v2 (๊ณต์‹ Site ํ•œ๊ธ€ ๋งค๋‰ด์–ผ)) 1.1 ํ˜•์ƒ ๊ด€๋ฆฌ ๋„๊ตฌ(Configuration..

goddaehee.tistory.com

https://yanacoding.tistory.com/4

 

[Git] ๊นƒ(git)๊ณผ ๊นƒํ—ˆ๋ธŒ(github)๋ž€ ๋ฌด์—‡์ธ๊ฐ€?

1. GIT์ด๋ž€ ๋ฌด์—‡์ธ๊ฐ€?    ๊นƒ(Git)์€ 2005๋…„์— ๋ฆฌ๋ˆ„์Šค ํ† ๋ฅด๋ฐœ์Šค์— ์˜ํ•ด ๊ฐœ๋ฐœ๋œ '๋ถ„์‚ฐ ๋ฒ„์ „๊ด€๋ฆฌ ์‹œ์Šคํ…œ(Distributed Version Control Systems - DVCS)'์œผ๋กœ, ์ปดํ“จํ„ฐ ํŒŒ์ผ์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ถ”์ ํ•˜๊ณ  ์—ฌ๋Ÿฌ๋ช…์˜ ์‚ฌ์šฉ์ž๋“ค.

yanacoding.tistory.com

 

'Git' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Git] Git branch strategy ๋ช…๋ช… ๊ทœ์น™ ๋ฐ ์ข…๋ฅ˜  (0) 2022.07.03