Skip to content

Latest commit

ย 

History

History
28 lines (23 loc) ยท 2.09 KB

06_commit.md

File metadata and controls

28 lines (23 loc) ยท 2.09 KB

Commitํ•˜์—ฌ GIT์— ์ €์žฅํ•˜๊ณ , ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

Staging Area์—์„œ Commitํ•˜์—ฌ GIT์— ์ €์žฅํ•˜๊ธฐ

  • commit์„ ํ•˜๊ณ  ์‹ถ์€ ํŒŒ์ผ์ด ์žˆ๋‹ค๋ฉด ํ•ด๋‹น ํŒŒ์ผ๋งŒ git add ํŒŒ์ผ๋ช…๋ฅผ ์ด์šฉํ•ด Staging Area๋กœ ์˜ฎ๊ฒจ์ฃผ๋ฉด ๋œ๋‹ค
  • ํ˜„์žฌ ํด๋”์—๋Š” one.txt์™€ .gitignore์ด ์ €์žฅ๋˜์–ด ์žˆ๊ณ , git add .์„ ์ด์šฉํ•ด ๋ชจ๋“  ํŒŒ์ผ์„ ์˜ฎ๊ฒจ์คฌ๋‹ค
  • ์ดํ›„ git commit -m "์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€"๋ฅผ ์ž…๋ ฅํ•˜๋ฉด Staging Area์˜ ํŒŒ์ผ๋“ค์ด GIT์— ์ €์žฅ๋œ๋‹ค

  • git log๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด, commit์˜ ์ด๋ ฅ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค



์ €์žฅ๋œ GIT version ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

  • ์—ฌ๋Ÿฌ๊ฐœ์˜ commit์ด ๋งŒ๋“ค์–ด์ ธ ์žˆ๋‹ค๋ฉด, ์–ธ์ œ๋“ ์ง€ ๊ฐ๊ฐ์˜ version์œผ๋กœ ๋˜๋Œ์•„๊ฐˆ ์ˆ˜ ์žˆ๋‹ค
  • ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด two.txt์™€ three.txt๋ฅผ ์ถ”๊ฐ€ํ•ด ๊ฐ๊ฐ commitํ•˜์—ฌ ์ด 3๊ฐœ์˜ version์„ ๋งŒ๋“ค์—ˆ๋‹ค

  • git log ๋ฅผ ์ด์šฉํ•ด ๋˜๋Œ์•„๊ฐ€๊ณ  ์‹ถ์€ version์˜ hash code๋ฅผ 7์ž๋ฆฌ ์ด์ƒ ๋ณต์‚ฌํ•ด ์ค€๋‹ค
    • git log --oneline์„ ์ด์šฉํ•˜๋ฉด ๋” ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ณผ ์ˆ˜ ์žˆ๋‹ค
  • git checkout ํ•ด์‹œ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ํ•ด๋‹น version์œผ๋กœ ๋˜๋Œ์•„๊ฐˆ ์ˆ˜ ์žˆ๋‹ค
  • ์•„๋ž˜์™€ ๊ฐ™์ด second commit์œผ๋กœ ๋Œ์•„๊ฐ€๊ฒŒ ๋˜๋ฉด three.txt๊ฐ€ ํ”์ ๋„ ์—†์ด ์‚ฌ๋ผ์ง„ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค

  • ํ˜„์žฌ thrid commit์ด ํ™”๋ฉด์— ๋‚˜ํƒ€๋‚˜๊ณ  ์žˆ์ง€ ์•Š์€๋ฐ, git log --all ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํ™•์ธ์ด ๊ฐ€๋Šฅํ•˜๋‹ค
    • git log --oneline --graph --all์ฒ˜๋Ÿผ ์—ฌ๋Ÿฌ ์˜ต์…˜์„ ๋ณ‘๋ ฌ๋กœ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐ€๋…์„ฑ์„ ๋†’์ผ ์ˆ˜ ์žˆ๋‹ค
  • ๋‹ค์‹œ third commit ์ƒํƒœ๋กœ ๋Œ์•„๊ฐ€๋ ค๋ฉด git checkout master ๋˜๋Š” git checkout ํ•ด์‹œ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์ž