Post

Git checkout ๐Ÿ‘‰ switch & restore

Git 2.23 ๋ถ€ํ„ฐ checkout์˜ ๊ธฐ๋Šฅ์ด switch์™€ restore๋กœ ๋ถ„๋ฆฌ๋˜์—ˆ๋‹ค.

  • checkout : Switch branches or restore working tree files
  • switch: Switch branches
  • restore: Restore working tree files


์ฐธ๊ณ ์‚ฌ์ดํŠธ

switch

branch๋ฅผ ๋ณ€๊ฒฝํ•œ๋‹ค.

1
git switch develop

branch๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ํ•ด๋‹น ๋ธŒ๋Ÿฐ์น˜๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค.

1
git switch -c new-branch


Git ๊ณต์‹ ๋ฌธ์„œ - switch

restore

์ž‘์—…์ค‘์ธ ํŒŒ์ผ์„ ๋ณต์›ํ•œ๋‹ค.

1
git restore hello.c

์ƒ‰์ธ์—์„œ HEAD์˜ ๋ฒ„์ „๊ณผ ์ผ์น˜ํ•˜๋„๋ก ํŒŒ์ผ์„ ๋ณต์› (git-reset[1]์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๊ณผ ๋™์ผํ•จ)

1
git restore --staged hello.c


Git ๊ณต์‹ ๋ฌธ์„œ - restore

This post is licensed under CC BY 4.0 by the author.