Skip to main content

non-fast-forward ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ

Git์—์„œ ์ปค๋ฐ‹์„ ์žƒ์ง€ ์•Š๊ณ  ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ ํ‘ธ์‹œ๊ฐ€ ๊ฑฐ๋ถ€๋ฉ๋‹ˆ๋‹ค.

๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๊ฐ€ ์‚ฌ์šฉ์ž์™€ ๋™์ผํ•œ ๋ถ„๊ธฐ์— ํ‘ธ์‹œํ•œ ๊ฒฝ์šฐ Git์—์„œ ๋ณ€๊ฒฝ ๋‚ด์šฉ์„ ํ‘ธ์‹œํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

$ git push origin main
> To https://github.com/USERNAME/REPOSITORY.git
>  ! [rejected]        main -> main (non-fast-forward)
> error: failed to push some refs to 'https://github.com/USERNAME/REPOSITORY.git'
> To prevent you from losing history, non-fast-forward updates were rejected
> Merge the remote changes (e.g. 'git pull') before pushing again. See the
> 'Note about fast-forwards' section of 'git push --help' for details.

์›๊ฒฉ ๋ถ„๊ธฐ์˜ ๋ณ€๊ฒฝ ๋‚ด์šฉ์„ ๋กœ์ปฌ๋กœ ๋ณ€๊ฒฝํ•œ ๋‚ด์šฉ๊ณผ ํŽ˜์น˜ํ•˜๊ณ  ๋ณ‘ํ•ฉํ•˜์—ฌ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git fetch origin
# Fetches updates made to an online repository
$ git merge origin YOUR_BRANCH_NAME
# Merges updates made online with your local work

๋˜๋Š” ๋‘ ๋ช…๋ น์„ ํ•œ ๋ฒˆ์— ๋ชจ๋‘ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฐ๋งŒ git pull์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git pull origin YOUR_BRANCH_NAME
# Grabs online updates and merges them with your local work