[Git] Working directory & Staging area & Repository

im_taehoยท2023๋…„ 1์›” 7์ผ
0
post-thumbnail

๐Ÿšฉ Git์˜ 3๊ฐ€์ง€ ๊ณต๊ฐ„

๐Ÿ’ก Working directory

  • Untracked : Add๋œ ์  ์—†๊ฑฐ๋‚˜ ignore๋œ ํŒŒ์ผ
  • Tracked : Add๋œ ์  ์žˆ๊ณ  ๋ณ€๊ฒฝ๋‚ด์—ญ์ด ์žˆ๋Š” ํŒŒ์ผ
  • $ git add๋กœ Staging area๋กœ ์ด๋™ ๊ฐ€๋Šฅ


๐Ÿ’ก Staging area

  • ์ปค๋ฐ‹์„ ์œ„ํ•œ ์ค€๋น„ ๋‹จ๊ณ„
  • $ git commit๋กœ Repository๋กœ ์ด๋™ ๊ฐ€๋Šฅ


๐Ÿ’ก Repository

  • ์ปค๋ฐ‹๋œ ์ƒํƒœ

๐Ÿ’ก ํŒŒ์ผ์„ Staging area โ†’ Working directory๋กœ ์ด๋™

$ git restore --staged <ํŒŒ์ผ ์ด๋ฆ„>
  • ์ดˆ๊ธฐ ์ƒํƒœ
  • ์œ„ ๋ช…๋ น์–ด๋กœ ํŒŒ์ผ ํ•˜๋‚˜๋ฅผ Working directory๋กœ ์ด๋™ํ•˜๋ฉด


๐Ÿ’ก ํŒŒ์ผ์„ Working directory์—์„œ๋„ ์ œ๊ฑฐ

$ git restore <ํŒŒ์ผ ์ด๋ฆ„>
  • Working directory์—์„œ๋„ ํŒŒ์ผ์„ ์ œ๊ฑฐํ•˜๋ฉด ์ด์ „ ์ปค๋ฐ‹ ์ƒํƒœ๋กœ ๋Œ์•„๊ฐ


๐Ÿšฉ ํŒŒ์ผ์˜ ์‚ญ์ œ์™€ ์ด๋™์„ ํ•˜๋Š” 2๊ฐ€์ง€ ๋ฐฉ๋ฒ•

๐Ÿ’ก git rm

$ git rm <ํŒŒ์ผ ์ด๋ฆ„>
  • ํŒŒ์ผ์ด ์‚ญ์ œ๋˜๊ณ  ๋ณ€๊ฒฝ๋‚ด์—ญ์ด Staging area์— ์กด์žฌ
  • ๊ทธ๋ƒฅ ํŒŒ์ผ์„ ์‚ญ์ œ ํ•˜๋ฉด ๋ณ€๊ฒฝ๋‚ด์—ญ์ด Working directory์— ์กด์žฌ


๐Ÿ’ก git mv

$ git mv <๋ณ€๊ฒฝ์ „ ํŒŒ์ผ๋ช…> <๋ณ€๊ฒฝํ›„ ํŒŒ์ผ๋ช…>
  • ํŒŒ์ผ ์ด๋ฆ„์ด ๋ณ€๊ฒฝ๋˜๊ณ  ๋ณ€๊ฒฝ๋‚ด์—ญ์ด Staging area์— ์กด์žฌ
  • ๊ทธ๋ƒฅ ํŒŒ์ผ ์ด๋ฆ„์„ ๋ณ€๊ฒฝํ•˜๋ฉด ๋ณ€๊ฒฝ๋‚ด์—ญ์ด Working directory์— ์กด์žฌ
profile
๋ฐ˜๊ฐ‘์Šต๋‹ˆ๋‹ค :)

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