๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Programming/Git

(2)
[Git Hook] pre commit ์œผ๋กœ ์žฅ์•  ์˜ˆ๋ฐฉํ•˜๊ธฐ(ft. husky, osascript) d์ตœ์‹  ์šด์˜ ์ค‘์ธ ์•ฑ์—์„œ ํŠน์ • ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๋‹ค ์žฅ์• ๊ฐ€ ๋‚ฌ์—ˆ๋‹ค. ์ผ๋ถ€ ์„œ๋น„์Šค์—์„œ ์‚ฌ์šฉ์ด ๋ถˆ๊ฐ€๋Šฅํ•œ ๋ฉ”์„œ๋“œ๊ฐ€ ์žˆ์—ˆ๋Š”๋ฐ, ํ™˜๊ฒฝ์ด ๋ถ„์‚ฐ๋˜๊ณ  ๋ณต์žกํ•˜๋‹ค๋ณด๋‹ˆ ๊ฐœ๋ฐœ์ž๊ฐ€ ํ…Œ์ŠคํŠธ๋ฅผ ๋†“์นœ ์ผ€์ด์Šค์˜€์—ˆ๋‹ค. ์ด ๋ถ€๋ถ„์„ ๊ฐœ์„ ํ•˜๊ณ  ๋น„์Šทํ•œ ์žฅ์• ๋ฅผ ์˜ˆ๋ฐฉํ•˜๊ธฐ ์œ„ํ•ด์„œ pre commit rule์„ ์ถ”๊ฐ€ํ•ด์„œ ํŠน์ • ํ‚ค์›Œ๋“œ๊ฐ€ ์†Œ์Šค์— ์ถ”๊ฐ€๋˜๋ฉด ์•ˆ๋‚ด๋ฅผ ์œ„ํ•œ ํŒ์—…์„ ๋„์šฐ๊ฒŒ ํ–ˆ๋‹ค. ๐Ÿค– ํ™˜๊ฒฝ๊ฐœ๋ฐœํŒ€์˜ ํ™˜๊ฒฝ์€ Mac์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๊ณ  Husky plugin์ด ์„ค์น˜๋˜์–ด ์žˆ์—ˆ๋‹ค. git์€ ๊ฐœ๋ฐœ์ž๊ฐ€ commit์„ ์ˆ˜ํ–‰ํ•˜๋ฉด, commit ์ด ์ˆ˜ํ–‰๋˜๊ธฐ ์ „์— ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰๋˜๊ฒŒ๋”ํ•˜๋Š” pre-commit ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•œ๋‹ค.๋ฐฉ๋ฒ•์€ ํ”„๋กœ์ ํŠธ์˜ .git/ ํ•˜์œ„์—  "pre-commit"์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๋œ๋‹ค.ํ•˜์ง€๋งŒ, git์—์„œ ์ œ๊ณตํ•˜๋Š” pre-commit์˜ ๊ฒฝ์šฐ, ๊ฐœ์ธ ๋กœ์ปฌ..
๊นƒํ—™ ํŠน์ • ๋ธŒ๋žœ์น˜ ํด๋ก  ํ•˜๊ธฐ / github branch clone ํŒ€์œผ๋กœ ์ง„ํ–‰๋˜์—ˆ๋˜ ํ”„๋กœ์ ํŠธ์—์„œ ์ž์‹ ์˜ ๋ธŒ๋žœ์น˜ ๊ฐ€์ ธ์˜ฌ ๋•Œ, ์‚ฌ์šฉํ•˜๊ธฐ ์ข‹์Šต๋‹ˆ๋‹ค. ๐Ÿ“ ํŠน์ • branch cloneํ•˜๊ธฐ git clone -b [๋ธŒ๋žœ์น˜ ์ด๋ฆ„] --single-branch [๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ฃผ์†Œ] ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ฃผ์†Œ๋Š” HTTPS, SSH ์ฃผ์†Œ ๋ชจ๋‘ ๊ฐ€๋Šฅ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ์‹œ git clone -b space_jin --single-branch https://github.com/space-team/toy-proj space-team ๊นƒํ—™์˜ toy-proj ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์˜ space_jin ๋ธŒ๋žœ์น˜๋งŒ ํด๋ก  ํ•ฉ๋‹ˆ๋‹ค.

728x90