[๐ŸŽ GIT] non-fast-forward ๋ฌธ์ œ

์ดํ•˜์–€ยท2024๋…„ 3์›” 20์ผ
0

๐Ÿ˜ธ Git & GitHub

๋ชฉ๋ก ๋ณด๊ธฐ
6/6

๐Ÿ˜“ ๋ฌธ์ œ

  • ๊ธฐ์กด ๋ธŒ๋žœ์น˜๊ฐ€ ์•„๋‹Œ ์˜คํƒ€๋กœ ์ธํ•œ ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๊ฐ€ 1๊ฐœ ๋” ๋งŒ๋“ค์–ด์ ธ ๊ธฐ์กด ๋ธŒ๋žœ์น˜ โฌ…๏ธ์˜คํƒ€๋กœ ์ธํ•œ ์ƒˆ ๋ธŒ๋žœ์น˜ Merge๋ฅผ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๊ทธ ํ›„, ์ธํ…”๋ฆฌ์ œ์ด๋ฅผ ํ†ตํ•ด ์ถ”๊ฐ€๋กœ ์ž‘์—…์„ ํ–ˆ๊ณ  ์ •์ƒ์ ์œผ๋กœ commit์„ ๋๋‚ธ ํ›„ push ๋ช…๋ น์–ด๋ฅผ ์ž‘์„ฑํ–ˆ์œผ๋‚˜ ๋‹ค์Œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.
[rejected] -> (non-fast-forward) error: failed to push some refs to



๐Ÿšง ์›์ธ

๐Ÿ”—๊นƒํ—ˆ๋ธŒ non-fast-forward ์—๋Ÿฌ ํ•ด๊ฒฐํ•˜๊ธฐ
Github Repository์— ์žˆ๋Š” ์›๊ฒฉ ์ €์žฅ์†Œ์™€ ๋กœ์ปฌ์— ์ƒ์„ฑ๋œ ์ €์žฅ์†Œ ๊ฐ„ ๊ณตํ†ต๋ถ„๋ชจ๊ฐ€ ์—†๋Š” ์ƒํƒœ์—์„œ Merge๋ฅผ ์‹œ๋„ํ•ด ๋ฐœ์ƒ๋˜๋Š” ๋ฌธ์ œ๋กœ ํŒŒ์•…ํ–ˆ์Šต๋‹ˆ๋‹ค.
๋˜ํ•œ, main ๋ธŒ๋žœ์น˜๊ฐ€ ์•„๋‹Œ ๋ณ„๋„์˜ ๋ธŒ๋žœ์น˜์—์„œ ์ž‘์—…์„ ์ง„ํ–‰ํ•˜๋˜ ๋„์ค‘์— git checkout์œผ๋กœ ๊ธฐ์กด ๋ธŒ๋žœ์น˜ ์ด๋ฆ„์— ์˜คํƒ€๊ฐ€ ๋ฐœ์ƒํ•ด Local ํ™˜๊ฒฝ์—์„œ๋Š” ๋ณ„๋„ ๋ธŒ๋žœ์น˜๋ฅผ ์ œ์™ธํ•œ ํƒ€ ๋ธŒ๋žœ์น˜๊ฐ€ 1๊ฐ€์ง€ ๋” ์ƒ๊ธฐ๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

  • ์˜คํƒ€ ์ด์ „
Local
โ””โ”€โ”€ main
โ””โ”€โ”€ HayanLee
|
Remote
โ””โ”€โ”€ main
โ””โ”€โ”€ HayanLee
  • ์˜คํƒ€ ์ดํ›„
Local
โ””โ”€โ”€ main
โ””โ”€โ”€ HayanLee
โ””โ”€โ”€ Hayanlee //์ด ๊ณณ์—์„œ ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๊ฐ€ ๋งŒ๋“ค์–ด์ง.
|
Remote
โ””โ”€โ”€ main
โ””โ”€โ”€ HayanLee
  • ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ์˜คํƒ€๋กœ ์ƒ์„ฑํ•œ Hayanlee ๋ธŒ๋žœ์น˜๋ฅผ ๊ธฐ์กด ๋ธŒ๋žœ์น˜์ธ HayanLee ๋ธŒ๋žœ์น˜๋กœ Mergeํ•ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค.



๐Ÿš€ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

์šฐ์„ , ์œ„ ์ถœ์ฒ˜์˜ ๋ชจ๋“  ๋ฐฉ๋ฒ•์„ ์‹œ๋„ํ–ˆ์œผ๋‚˜ ์ •์ƒ์ ์œผ๋กœ ์ฒ˜๋ฆฌ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.
์ด์— ๋”ฐ๋ผ ๊ฐ•์ œ๋กœ ๋‹ค์‹œ push๋ฅผ ์‹œ๋„ํ•˜์—ฌ ๋‹ค์Œ ์—๋Ÿฌ๊ฐ€ ์ถ”๊ฐ€์ ์œผ๋กœ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.

Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.

1๏ธโƒฃ ์ฒซ๋ฒˆ์งธ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• โŒ

  • ๋กœ์ปฌ ๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ ๋ฃจํŠธ ์œ„์น˜๋กœ ์ด๋™ ํ›„ rm -f .git/index.lock ์‹คํ–‰


2๏ธโƒฃ ๋‘๋ฒˆ์งธ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• โญ•

  1. ์–ด๋–ป๊ฒŒ๋“  ๊ฐ•์ œ๋กœ Merge๋ฅผ ์‹œํ‚ค๊ธฐ
  • ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด ๊ฐ•์ œ Merge๋ฅผ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.
git fetch origin
git merge origin HayanLee

  1. ์ปดํ“จํ„ฐ์— ์ €์žฅ๋œ ํ”„๋กœ์ ํŠธ๋ฅผ ์™„์ „ํžˆ ์‚ญ์ œ
  • ์ปดํ“จํ„ฐ์˜ ํ”„๋กœ์ ํŠธ ๋ฃจํŠธ ํด๋”๋ฅผ ์™„์ „ํžˆ ์‚ญ์ œํ–ˆ์Šต๋‹ˆ๋‹ค.

  1. GitHub Repository์—์„œ ๋‹ค์‹œ cloneํ•˜๊ธฐ
  • ๋‹ค์‹œ ๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ์— ์ ‘๊ทผํ•ด ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ•œ ๋‹ค์Œ cloneํ–ˆ์Šต๋‹ˆ๋‹ค.

  1. remote branch๋ฅผ Local branch๋กœ ๊ฐ€์ ธ์˜ค๊ธฐ

  1. ์ž‘์—… ํ›„ ๋‹ค์‹œ add&commit&push ํ…Œ์ŠคํŠธ

โœ…Push ์„ฑ๊ณต




๐Ÿ–Š๏ธ์ •๋ฆฌ

  • ์˜คํƒ€๋กœ ์ธํ•ด ์ƒ์„ฑํ•œ ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๋ฅผ ๊ธฐ์กด ๋ธŒ๋žœ์น˜์— Mergeํ•˜๋ ค ์‹œ๋„
  • ์ฒซ Merge๋Š” ๋ฌธ์ œโŒ
    ๊ทธ๋Ÿฌ๋‚˜ ์ด ๋‹จ๊ณ„์—์„œ ๋ณด์ด์ง€ ์•Š๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋˜ ๊ฒƒ์œผ๋กœ ์ถ”์ •
  • ๊ทธ ๋‹ค์Œ ํŒŒ์ผ ๋ณ€๊ฒฝ ํ›„ ๋‹ค์‹œ Push ๋ฐ Merge ์‹œ๋„
    โžก๏ธ Merge๊ฐ€ ์ œ๋Œ€๋กœ ์ด๋ค„์ง€์ง€ ์•Š์•„ ๊ฐ•์ œ๋กœ Merge
    โžก๏ธ ๊ทธ ํ›„ Push ์ง„ํ–‰
  • ๊ทธ ๋‹ค์Œ ๋ฌธ์ œ๊ฐ€ ๋˜๋Š” ๋ธŒ๋žœ์น˜๋ฅผ ์™„์ „ํžˆ ์‚ญ์ œํ•˜๊ธฐ ์œ„ํ•ด ๋กœ์ปฌ ์ปดํ“จํ„ฐ์— ์ €์žฅ๋œ ํ”„๋กœ์ ํŠธ ํด๋” ์ž์ฒด๋ฅผ ์‚ญ์ œ
  • ํ”„๋กœ์ ํŠธ๋ฅผ ๋‹ค์‹œ cloneํ•˜์—ฌ ์ž ์ •์  ๋ฌธ์ œ ์ œ๊ฑฐ!



โ™ป๏ธ ํšŒ๊ณ 

๋ฌธ์ œ์˜ ๋ฐœ์ƒ ์›์ธ๊ณผ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ๋‹ค์–‘ํ•˜๊ฒŒ ๊ฐ•๊ตฌํ–ˆ์ง€๋งŒ, ๊ฒฐ๊ตญ ํ•ด๊ฒฐํ•˜์ง€ ๋ชปํ•ด ํ”„๋กœ์ ํŠธ๋ฅผ ๋‹ค์‹œ cloneํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ํ•ด๊ฒฐํ•œ ์ ์ด ์•„์‰ฌ์› ์Šต๋‹ˆ๋‹ค..
๋” ๊ณต๋ถ€ํ•ด์„œ ๋‹ค์Œ์—๋Š” ๊ผญ ์ถฉ๋Œ์„ ํ’€์–ด์„œ ํ•ด๊ฒฐํ•˜๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค๐Ÿ˜ญ

profile
์–ธ์  ๊ฐ€ ๋‚ด ์ฝ”๋“œ๋กœ ์„ธ์ƒ์— ๊ธฐ์—ฌํ•  ์ˆ˜ ์žˆ๋„๋ก, BE&Data Science ๊ฐœ๋ฐœ ๊ธฐ๋ก ๋…ธํŠธโ˜˜๏ธ

0๊ฐœ์˜ ๋Œ“๊ธ€