๐Ÿšจ Git ํ˜‘์—…์‹œ ๊ฒช์€ ๋ฌธ์ œ

wodnr_Pยท2023๋…„ 9์›” 13์ผ
0

์‹ค์‹œ๊ฐ„ ๊ฒฝ๋งค ์„œ๋น„์Šค ํŒ€ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ ์ค‘ merge ๊ณผ์ •์—์„œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค!

  • ์ดํ›„์—๋„ ๊ฐ™์€ ์ƒํ™ฉ์ด ๋ฐœ์ƒํ–ˆ์„ ๋•Œ ๋Œ€์ฒ˜๋ฅผ ์ž˜ ํ•˜๊ธฐ ์œ„ํ•ด
  • ๊ฐ™์€ ์ƒํ™ฉ์˜ ์˜ค๋ฅ˜๋ฅผ ๋งž์ดํ•˜์‹  ๋ถ„๋“ค์„ ์œ„ํ•ด ์ด ๊ธ€์„ ๋‚จ๊น๋‹ˆ๋‹ค.

๐Ÿšจ ๋ฌธ์ œ ์ƒํ™ฉ

  • ๊ฐ์ž์˜ ์—ญํ• ์„ Django app์„ ๊ธฐ์ค€์œผ๋กœ ๋‚˜๋ˆˆ ์ƒํ™ฉ
  • ๊ฐ์ž DB Model์„ ์ž‘์„ฑํ•˜์—ฌ develop branch์— merge
  • repo ์ฑ…์ž„์ž๊ฐ€ develop branch์— DB migrations์„ ์ง„ํ–‰ํ•˜์—ฌ ์˜ฌ๋ฆผ
  • ํŒ€์› ๋ถ„ ์ค‘ ํ•œ๋ถ„์ด pull์„ ์ง„ํ–‰ํ•˜์ง€ ์•Š๊ณ , DB Model์„ ์ˆ˜์ • ํ•˜๊ณ  migrations ํ›„ PR

๊ฒฐ๊ตญ ์ด๋ฏธ migrations์„ ์ง„ํ–‰ํ•œ develop branch์˜ migration ํด๋”์™€ PR ์š”์ฒญ์„ ํ•˜์‹  ํŒ€์›์˜ migration ํด๋” ๋‚ด๋ถ€์˜ ํŒŒ์ผ๊ณผ ์ถฉ๋Œ ๋ฐœ์ƒ


โญ๏ธ ์›์ธ

migration์ด ๊ฐ€์žฅ ์ฒ˜์Œ ์ง„ํ–‰๋˜๋ฉด 0001_intial.py๊ฐ€ ์ƒ์„ฑ๋˜๋Š”๋ฐ, ํ˜‘์—…์‹œ ์ด๋ฅผ pull ๋ฐ›์ง€ ์•Š๊ณ  ๋‹ค์‹œ migration์„ ์ง„ํ–‰ํ•˜๋ฉด 0002_intial.py ํŒŒ์ผ์ด ์ƒ์„ฑ๋˜๋Š”๊ฒŒ ์•„๋‹ˆ๋ผ 0001_intial.py์ด ์ƒ์„ฑ๋˜๊ณ  merge ๊ณผ์ •์—์„œ ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ


๐Ÿ’ก ํ•ด๊ฒฐ

  • ๋กœ์ปฌ์—์„œ migrationํ•œ ํŒŒ์ผ๋“ค์„ ์ง€์šฐ๊ณ , develop branch๋ฅผ ๋‹ค์‹œ pull์„ ๋ฐ›์€ ํ›„ merge

ํ•˜์ง€๋งŒ 3๋ช… ์ด์ƒ์ด git์„ ํ†ตํ•ด ํ˜‘์—…์„ ํ•˜๋Š” ๊ณผ์ •์—์„œ ๋‹ค์‹œ DB migration ์ถฉ๋Œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ๊ฒƒ์„ ์šฐ๋ คํ–ˆ๋‹ค.
๊ทธ๋ž˜์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ ํ•ด๊ฒฐํ–ˆ๋‹ค.

  • .gitignore ํŒŒ์ผ์— migration ํด๋” ์ž์ฒด๋ฅผ ์ถ”๊ฐ€

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด git์— ์˜ฌ๋ผ๊ฐ€์ง€ ์•Š๊ฒŒ ๊ด€๋ฆฌํ•˜์—ฌ ์ถฉ๋Œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐ ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋‹จ, ๋ฐฐํฌ ๊ณผ์ •์—์„œ๋Š” ๋‹ค์‹œ git์— ์˜ฌ๋ผ๊ฐ€๋„๋ก ์กฐ์น˜๋ฅผ ์ทจํ•ด์•ผํ•˜๋ฉฐ, ๊ฐœ๋ฐœ ๊ณผ์ •์—์„œ๋งŒ ์ถฉ๋Œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•จ์ด๋‹ค.

๋˜ํ•œ ์ด ๋ฐฉ๋ฒ•์€ DB ๊ด€๋ จ ์ฝ”๋“œ์— ๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ๋ฐœ์ƒํ–ˆ์„ ๋•Œ, pull์„ ๋ฐ›๊ณ  ๊ฐœ์ธ์ด migration์„ ์ง„ํ–‰ํ•ด์•ผ ํ•œ๋‹ค๋Š” ๋ฒˆ๊ฑฐ๋กœ์›€์ด ์žˆ๋‹ค.

โœ‹๐Ÿป [์ถ”๊ฐ€์ ์ธ ๊ณ ๋ ค์‚ฌํ•ญ]

์ด๋ ‡๊ฒŒ .gitignore ํŒŒ์ผ์— ํ•ญ๋ชฉ์„ ์ถ”๊ฐ€ํ–ˆ์„ ๋•Œ ์ ์šฉ์ด ์•ˆ๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š”๋ฐ,
์ด๋Š” git์— .gitignore ํ•ญ๋ชฉ๋“ค์ด ์บ์‹œ๋˜์–ด์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค.

git rm -r --cached

๋”ฐ๋ผ์„œ ์œ„ ๋ช…๋ น์–ด๋ฅผ ์ ์šฉํ•œ ํ›„ git add ., git push ~ ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด ๋ฌธ์ œ์—†์ด .gitignore๊ฐ€ ์ž‘๋™ํ•œ๋‹ค.


ํšŒ๊ณ 

ํ˜ผ์ž ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ–ˆ์„ ๋•Œ ๋ณด๋‹ค ํŒ€ ํ”„๋กœ์ ํŠธ์‹œ ๊ฒฝํ—˜ํ•˜๋Š” ๋ฒ”์œ„๊ฐ€ ๋” ํฌ๊ธฐ ๋•Œ๋ฌธ์—, ์—๋Ÿฌ์‚ฌํ•ญ์ด๋‚˜ ๋ฌธ์ œ์ƒํ™ฉ์ด ๋ฐœ์ƒํ–ˆ์„ ๋•Œ ๋ฐฐ์šฐ๊ฑฐ๋‚˜, ๋‹ค์–‘ํ•œ ๋ฌธ์ œ๋ฅผ ๋Œ€์ฒ˜ํ•  ์ˆ˜ ์žˆ์–ด์„œ ์˜คํžˆ๋ ค ๋” ์ข‹์€ ๊ฒƒ ๊ฐ™๋‹ค.

merge ๊ณผ์ •์€ ์–ด๋–ค ์ƒˆ๋กœ์šด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ง€ ๋ชจ๋ฅด๊ธฐ์— ํ•ญ์ƒ ๊ธด์žฅ์ด ๋˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค :D

profile
๋ฐœ์ „ํ•˜๋Š” ๊ฟˆ๋‚˜๋ฌด ๊ฐœ๋ฐœ์ž / ์ทจ์ค€์ƒ

0๊ฐœ์˜ ๋Œ“๊ธ€