๐Ÿ“š Computer Science/Git

[Git] ์›๊ฒฉ์ €์žฅ์†Œ์— Push ํ•œ Commit ์‚ญ์ œํ•˜๊ธฐ

ibelieveinme 2024. 2. 15. 14:21
728x90

 

1. ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ์‚ญ์ œํ•  commit ์„ ํ™•์ธ.

git log

 

 

2. ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰์— push ํ•œ(๊ฐ€์žฅ ์œ„์— ์žˆ๋Š”) commit ์„ ์ง€์šฐ๊ณ  ์‹ถ๊ธฐ ๋•Œ๋ฌธ์— ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ commit ์„ ์‚ญ์ œํ•œ๋‹ค.

git reset HEAD^

 

 

3. ๊ทธ๋ฆฌ๊ณ  ๋‚ด๊ฐ€ commit ์„ ์ง€์› ๋‹ค๋Š” ๊ฒƒ์„ github ์„œ๋ฒ„์— ์•Œ๋ ค์ฃผ์–ด github ๋‚ด์—์„œ๋„ ํ•ด๋‹น commit ์„ ์‚ญ์ œํ•˜๋„๋ก ํ•œ๋‹ค.

git push -f origin "๋ธŒ๋žœ์น˜๋ช…"

 

cf) master ์—์„œ push ํ•œ commit ์„ ์‚ญ์ œํ•˜๋ ค๋ฉด git push -f origin master ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

728x90