[Django]Git & Github

Jimin_Noteยท2022๋…„ 6์›” 2์ผ
0

๐ŸŒฑDjango

๋ชฉ๋ก ๋ณด๊ธฐ
6/13
post-thumbnail

๐Ÿ“Git

๐Ÿ‘‰ย Git : Version Control System (VCS)

โ‡’ ๋ญ๊ฐ€ ์ง„์งœ ์ตœ์ข…์ธ์ง€ ์•Œ๊ธฐ ์–ด๋ ค์›€

โ‡’์ˆ˜์ •ํ•  ๋•Œ๋งˆ๋‹ค ์ด๋ ฅ์„ ๋‚จ๊ฒจ ์ง„์งœ ์ตœ์ข…์„ ์•Œ ์ˆ˜ ์žˆ์Œ

<์ฝ”๋“œ ๋ฒ„์ „ ๊ด€๋ฆฌ์˜ ์ด์œ >

  • ์ˆ˜์ •ํ•  ๋•Œ ๋งˆ๋‹ค ํŒŒ์ผ์„ ์ƒˆ๋กœ ๋งŒ๋“ค๋ฉด ๊ด€๋ฆฌ๊ฐ€ ํž˜๋“ค๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉ
  • ์–ธ์ œ๋“  ์ด์ „ ๋ฒ„์ „์˜ ์ฝ”๋“œ๋กœ ๋Œ์•„๊ฐˆ ์ˆ˜ ์žˆ์Œ
  • ์ด๋ ฅ์„ ๋‚จ๊ธฐ๊ธฐ ์œ„ํ•ด
  • ํ•˜๋‚˜์˜ ํ”„๋กœ์ ํŠธ๋ฅผ ๋‘๊ณ  ์—ฌ๋Ÿฌ ๊ฐœ๋ฐœ์ž๋“ค์˜ ํ˜‘์—… ๊ฐ€๋Šฅ

๐Ÿ“Github

Github

  • Git์„ ์‚ฌ์šฉํ•œ ํ”„๋กœ์ ํŠธ๋“ค์˜ ์ €์žฅ์†Œ
  • ๊ฐœ๋ฐœ์ž๋“ค์˜ ์†Œ์…œ ๋„คํŠธ์›Œํฌ(๊ฐœ๋ฐœ์ž SNS)

๊นƒํ—ˆ๋ธŒ ๋งˆ์Šค์ฝ”ํŠธ โ€˜์˜ฅํ† ์บฃโ€™ใ…Žใ…Ž

๐Ÿ“ํ„ฐ๋ฏธ๋„ ์ƒ์—์„œ์˜ Git๋ช…๋ น์–ด

initgit initgit ์‹œ์ž‘
statusgit statusgit ์ƒํƒœ ํ™•์ธ
addgit addํŒŒ์ผ ์ˆ˜์ • ์ด๋ ฅ ๊ธฐ๋ก์ค€๋น„๋ณ€๊ฒฝ๋˜ ์ฝ”๋“œ๋“ค์€ ์–ด๋– ํ•œ ๊ณต๊ฐ„์— ๋‹ด์•„๋‘๊ธฐ
git add .
commitgit commitํŒŒ์ผ ์ˆ˜์ • ์ด๋ ฅ ๊ธฐ๋ก๋‹ด์•„๋‘” ์ฝ”๋“œ๋ฅผ ์ €์žฅ,๊ธฐ๋กํ•˜๋Š” ๋ช…๋ น์–ดgit commit -m "first"
loggit logcommit์ด๋ ฅ๋ณด๊ธฐcommit์„ ์–ด๋–ป๊ฒŒ ๋‚จ๊ฒผ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๋ช…๋ น์–ด
pushgit push
git remote add https์ฃผ์†Œ(ssh)

๐Ÿ“Github์— Repository๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์—…๋กœ๋“œํ•˜๊ธฐ

Git & Githubgit ์ดˆ๊ธฐํ™”

โ€ข ์ƒ์„ฑํ•œ ์žฅ๊ณ  ํ”„๋กœ์ ํŠธ๋ฅผ git์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ์ดˆ๊ธฐํ™”
โ€ข manage.py ์™€ ๊ฐ™์€ ๊ฒฝ๋กœ์—์„œ git initย ๋ช…๋ น์–ด๋กœ git ์ดˆ๊ธฐํ™”

git init

< .gitignore ์ƒ์„ฑ>

โ€ข ์†Œ์Šค๋ฅผ ๊ณต์œ ํ•˜๊ธฐ ์œ„ํ•œ git์— ์˜ฌ๋ฆฌ๊ณ  ์‹ถ์€๊ฒƒ ์˜ฌ๋ฆฌ๊ณ  ์‹ถ์ง€ ์•Š์€๊ฒƒ, ์˜ฌ๋ ค์„œ๋Š” ์•ˆ๋˜๋Š” ๊ฒƒ๋“ค์„ ๊ตฌ๋ถ„ํ•˜๊ธฐ ์œ„ํ•ด ๊นƒ์ด ์„ค์น˜๋œ ๋””๋ ‰ํ† ๋ฆฌ์—ย .gitignoreํŒŒ์ผ์„ ์ƒ์„ฑํ•ด์„œ ๊ด€๋ฆฌ
ex ) my_setiings.py

โ€ข ์•„๋ž˜ ์‚ฌ์ดํŠธ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ํ™˜๊ฒฝ์— ํ•ด๋‹นํ•˜๋Š” ํ‚ค์›Œ๋“œ๋ฅผ ์„ ํƒํ•˜๋ฉด, ์ž๋™์œผ๋กœ .gitignore ํŒŒ์ผ์— ์ •์˜ํ•  ์š”์†Œ๋“ค์„ ์ƒ์„ฑ.
gitignore.io
โ€ข ์•„๋ž˜ ํ‚ค์›Œ๋“œ๋ฅผ ์ถ”๊ฐ€ ํ›„ <python, pycharm, VisualStudioCode, vim, macOS, Linux, zsh> Createํ•˜๊ธฐ
โ€ข Create ํ•˜์—ฌ ๋‚˜์˜จ ๋‚ด์šฉ์„ย .gitignoreย ํŒŒ์ผ ์ƒ์„ฑ ํ›„, ๋ถ™์—ฌ๋„ฃ๊ธฐ

# ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™
cd 'ํ”„๋กœ์ ํŠธ ํด๋”๋ช…'

# .gitignore ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ
touch .gitignore

#.gitignore ํŽธ์ง‘
vi .gitignore

gitignore.io ๊ฒฐ๊ณผ ์ „์ฒด ๋ณต์‚ฌํ•ด์„œ
my_settings.py๊ฐ€์žฅ ํ•˜๋‹จ์— ์ถ”๊ฐ€

my_settings.py (๋ณด์•ˆ ๊ด€๋ จ ํŒŒ์ผ์€ github์— ์—…๋กœ๋“œ๐Ÿšซ)`

  • add & commit
git add .
git commit -m "Add: Django Project Setting"

Branch & Application ์ƒ์„ฑBranch ์ƒ์„ฑ

โ€ข feature/crudย ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑ & ์ด๋™

$ git branch ๋ธŒ๋žœ์น˜ ์ด๋ฆ„ # ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ
$ git checkout ๋ธŒ๋žœ์น˜ ์ด๋ฆ„ # ํ•ด๋‹น ๋ธŒ๋žœ์น˜๋กœ ์ด๋™ 

์ƒ์„ฑ๊ณผ ๋™์‹œ์— ์ด๋™ํ•˜๋Š” ๋ฐฉ๋ฒ•

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

Application ์ƒ์„ฑ
โ€ข settings.py ์„ค์ • ํ›„ app ์ƒ์„ฑ

python manage.py startapp products
โ€ข settings.py installed_apps ์ถ”๊ฐ€

# settings.py
INSTALLED_APPS = [
...
    'products', 
]`

Github Push
โ€ข git add & commit

git add .
git commit -m "Add: products application"

โ€ข Github repository branch push

git push origin "๋ธŒ๋žœ์น˜ ์ด๋ฆ„"
profile
Hello. I'm jimin:)

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