Git

[GitHub] ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜(branch) ๋งŒ๋“ค๊ธฐ

ํƒฑ์ ค 2021. 2. 9. 17:02

ํ˜‘์—… ์‹œ ์—ฌ๋Ÿฌ ๋ช…์ด ๋™์‹œ์— ๋‹ค๋ฅธ ์ž‘์—…์„ ํ•˜๋ ค๋ฉด branch๋ฅผ ๋งŒ๋“ค์–ด์•ผํ•œ๋‹ค.

๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜๋ฉด ํ•œ ํ”„๋กœ์ ํŠธ๋ฅผ ์—ฌ๋Ÿฌ ๋ช…์ด์„œ ์„œ๋กœ ๋‹ค๋ฅด๊ฒŒ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค.

 

CMD์—์„œ ์ž‘์—…

 

1. Branch ํ™•์ธ

git branch

๋ธŒ๋žœ์น˜๋ฅผ ๋งŒ๋“ค๊ธฐ ์ „์—๋Š” master ๋ธŒ๋žœ์น˜๋งŒ ์กด์žฌํ•œ๋‹ค.

git branch -r : ์›๊ฒฉ ์ €์žฅ์†Œ์˜ branch ๋ฆฌ์ŠคํŠธ ํ™•์ธ
git branch -a : ๋กœ์ปฌ, ์›๊ฒฉ ์ €์žฅ์†Œ์˜ branch ๋ฆฌ์ŠคํŠธ ํ™•์ธ
git push origin --delete [๋ธŒ๋žœ์น˜๋ช…] : ์›๊ฒฉ ๋ธŒ๋žœ์น˜ ์‚ญ์ œ

 

2. Branch ์ƒ์„ฑ ๋ฐ ์ด๋™

git branch [๋ธŒ๋žœ์น˜๋ช…]

์˜ˆ์‹œ๋กœ feature๋ผ๋Š” ์ด๋ฆ„์˜ ๋ธŒ๋žœ์น˜๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค.

 

์ƒ์„ฑ ํ›„ ๋‹ค์‹œ git branch ๋ช…๋ น์–ด๋กœ ํ™•์ธํ•˜๋ฉด

feature ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ ์™„๋ฃŒ!

 

์ด์ œ ์ƒ์„ฑํ•œ ๋ธŒ๋žœ์น˜๋กœ ์ด๋™ํ•˜๋ ค๋ฉด

git checkout [๋ธŒ๋žœ์น˜๋ช…]

๋ช…๋ น์–ด๋กœ ์ด๋™ํ•  ์ˆ˜ ์žˆ๋‹ค.


โ€ป ํŠน์ • repository clone

git clone -b [๋ธŒ๋žœ์น˜๋ช…] [์›๊ฒฉ ์ €์žฅ์†Œ url]

์œ„์˜ ๋ช…๋ น์–ด๋Š” ์•„๋ž˜์˜ ๋ช…๋ น์„ ํฌํ•จํ•˜๋Š” ์ž‘์—…์ด๋‹ค
git init
git remote add origin [์›๊ฒฉ ์ €์žฅ์†Œ url]
git fetch origin master
728x90