๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Git ๊ด€๋ จ

[Git Hub] : Git pull ์˜ค๋ฅ˜ ๋ฐ ํžŒํŠธ๊ตฌ๊ฐ„ ๋ฐœ์ƒ, rebase ์„ค์ •ํ•˜๊ธฐ.

by ๊ถŒ์Šพํ–„ 2023. 6. 8.
git pull ์‹œ๋„
% git pull origin update

// update ๋ธŒ๋žœ์น˜๋ฅผ ๋ฐ›์•„์˜ค๋Š” ๋ช…๋ น์–ด
 
hint ๊ตฌ๊ฐ„ ๋ฐœ์ƒ
ํ˜‘์—…์„ ํ†ตํ•ด์„œ ๋‹ค๋ฅธ์‚ฌ๋žŒ์ด pushํ•ด๋‘” ๋ ˆํผ์ง€ํ† ๋ฆฌ๋ฅผ ์ฒ˜์Œ์œผ๋กœ pull ํ•˜๊ฒŒ ๋˜๋Š” ๊ฒฝ์šฐ ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋œ๋‹ค.
From https://github.com/cooderyg/nbc-movie-team
 * branch            update     -> FETCH_HEAD
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint: 
hint:   git config pull.rebase false  # merge
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.
 

์œ„ ๋ฉ”์‹œ์ง€๋Š” Git์—์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ถ„๊ธฐ๋œ ๋ธŒ๋žœ์น˜(divergent branches)๋ฅผ ์กฐ์œจํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์•ˆ๋‚ด์ด๋‹ค.

ํ˜„์žฌ ๋ถ„๊ธฐ๋œ ๋ธŒ๋žœ์น˜๊ฐ€ ์žˆ๊ณ  ์ด๋ฅผ ์กฐ์œจํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ง€์ •ํ•ด์•ผ ํ•  ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ๋ฉ”์‹œ์ง€.

๋ถ„๊ธฐ๋œ ๋ธŒ๋žœ์น˜๋ฅผ ์กฐ์œจํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์Œ ์ค‘ ํ•˜๋‚˜์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์•ผ ํ•œ๋‹ค.

์ด ๋ช…๋ น์–ด๋Š” ๋‹ค์Œ pull ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์ „์— ์‹คํ–‰ํ•ด์•ผ ํ•œ๋‹ค.

git config pull.rebase false // ๋ณ‘ํ•ฉ(merge) ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ธŒ๋žœ์น˜๋ฅผ ์กฐ์œจํ•ฉ๋‹ˆ๋‹ค.

git config pull.rebase true // ๋ฆฌ๋ฒ ์ด์Šค(rebase) ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ธŒ๋žœ์น˜๋ฅผ ์กฐ์œจํ•ฉ๋‹ˆ๋‹ค.

git config pull.ff only // Fast-forward๋งŒ์„ ํ—ˆ์šฉํ•˜์—ฌ ์กฐ์œจํ•ฉ๋‹ˆ๋‹ค.
 

git config pull.rebase ์˜ ๊ฐ’์ด false ๋ผ๋ฉด merge๊ฐ€ ์ง„ํ–‰์ด ๋˜๋Š”๊ฒƒ์ด๊ณ ,
git config pull.rebase ์˜ ๊ฐ’์ด true ๋ผ๋ฉด rebase๊ฐ€ ์ง„ํ–‰์ด ๋˜๋Š”๋ฐ,

์ฃผ๋กœ pull.rebase๊ฐ’์ด true ๊ฐ’์„ ์„ ํ˜ธํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.

์ด์œ ๋Š” ๋ฐ”๋กœ merge ๊ฐ€ ์‹คํ–‰๋˜๋ฉด, ์ถฉ๋Œ์ด ์ผ์–ด๋‚˜๊ธฐ ๋•Œ๋ฌธ์—,
์šฐ์„  rebase๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์˜จ ํ›„์— ๊ฒ€ํ†  ํ›„
merge๋Š” ์ˆ˜๋™์ ์œผ๋กœ ์ง„ํ–‰ํ•œ๋‹ค๋Š” ์˜๋„์ด๋‹ค.

๋‚˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ธํŒ…์„ ๋งˆ์นœ ํ›„ ๋‹ค์‹œ pull์„ ์ง„ํ–‰ํ–ˆ๋‹ค.

% git config pull.rebase true // ํ•ด๋‹น๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด์„œ
  // pull.rebase์˜ ๊ฐ’์ด true๋กœ ์ถœ๋ ฅ๋˜๋„๋ก ์„ธํŒ…์„ ํ•ด์ฃผ๊ณ ,

% git pull origin update
// ๋‹ค์‹œ pull์„ ์ง„ํ–‰.
 

์ด๋ ‡๊ฒŒ ์ง„ํ–‰์„ ํ•˜๊ฒŒ ๋˜๋ฉด, ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜์™€ ๋งˆ์ฃผ์น˜๊ฒŒ ๋œ๋‹ค.

From https://github.com/cooderyg/nbc-movie-team
 * branch            update     -> FETCH_HEAD
fatal: Not possible to fast-forward, aborting.
 

๋‹ค์Œ ๋ช…๋ น์–ด๋กœ ๋‹ค์Œ ์ƒํ™ฉ์ง„ํ–‰์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

% git pull --rebase

// ์ถœ๋ ฅ ๊ฐ’
emote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 18 (delta 12), reused 18 (delta 12), pack-reused 0
Unpacking objects: 100% (18/18), 1.98 KiB | 144.00 KiB/s, done.
From https://github.com/cooderyg/nbc-movie-team
 * [new branch]      sub        -> origin/sub
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> delete
 

์šฐ๋ฆฌ๊ฐ€ ๋ฐฉ๊ธˆ ์ „ git pull --rebase ๋ฅผ ํ•˜๊ธฐ ์ „์— ๋‚˜์™”์—ˆ๋˜ ์˜ค๋ฅ˜์ค‘์—

fatal: Not possible to fast-forward, aborting.
 

๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” merge๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•˜๊ณ ,
merge๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ์—๋Š” ์ •๋ฐฉํ–ฅ์œผ๋กœ ์ง„ํ–‰ํ•˜๋Š” ๊ฒŒ ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๊ฐ€ ๋œจ๋ฉด์„œ ์ง„ํ–‰์„ ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์ด๋ผ ํ•œ๋‹ค.

์œ„์™€ ๊ฐ™์€ ๊ฒฝ์šฐ์—์„œ ๋ฌธ์ œ๋ฅผ ๊ทผ๋ณธ์ ์œผ๋กœ ํ•ด๊ฒฐํ•˜๋ ค๋ฉด fast-forward only ์˜ต์…˜์„ ๊บผ์•ผ ํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.
์˜ต์…˜์„ ๋„๋Š” ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

% git config --unset pull.ff
 

ํ•ด๋‹น ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ๊ณ  ๋‹ค์‹œ pull ์„ ์‹œ๋„ํ–ˆ๋‹ค.

% git pull origin update
From https://github.com/cooderyg/nbc-movie-team
 * branch            update     -> FETCH_HEAD
Successfully rebased and updated refs/heads/delete.
 

์„ฑ๊ณต์ ์œผ๋กœ update ๋ธŒ๋žœ์น˜๋ฅผ ๋ฐ›์•„์˜ค๋Š”๋ฐ ์„ฑ๊ณต !
git์— ๋Œ€ํ•ด์„œ๋Š” ์•„์ง ๋งŽ์ด ๋‹ค๋ค„๋ณด์ง€ ์•Š์•˜๋‹ค ๋ณด๋‹ˆ,
์˜ค๋ฅ˜๋ฅผ ๋ด๋„ ์ผ์ผํžˆ ๊ตฌ๊ธ€๋ง์„ ํ†ตํ•ด ํ•ด์„ํ•˜๊ณ  ๋ถ€๋”ชํ˜€๋ด์•ผ ํ•œ๋‹ค.

์‹œ๊ฐ„์ด ๋งŽ์ด ์†Œ์š”๋˜์ง€๋งŒ,
์–ธ๋Šฅ ๋งŽ์€ ์˜ค๋ฅ˜๋“ค์„ ๊ฒช์–ด๊ฐ€๋ฉด์„œ,
ํ•˜๋‚˜ํ•˜๋‚˜์— ๋…ธํ•˜์šฐ๊ฐ€ ์Œ“์˜€์œผ๋ฉด ํ•˜๋Š” ๋ฐ”๋žจ์ด๋‹ค.

 


2023/06/27

ํ˜„์žฌ ์ž‘์—…์ค‘์— ์œ„์™€ ๊ฐ™์€ ์ƒํ™ฉ์ด ํ•œ ๋ฒˆ๋” ๋ฐœ์ƒํ–ˆ๋‹ค.

๋˜‘๊ฐ™์ด ํžŒํŠธ๊ตฌ๊ฐ„์ด ๋ฐœ์ƒํ•˜์˜€๊ณ ,

๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ํ†ตํ•ด์„œ ์ง„ํ–‰์„ ํ–ˆ๋‹ค.

% git config --global pull.rebase true // ์ด๋ฒˆ์—๋Š” global์„ ํ†ตํ•ด ์ „์—ญ์œผ๋กœ ์„ธํŒ…์‹œ๋„.

% git pull origin main
// ๋‹ค์‹œ pull์„ ์ง„ํ–‰.
 

์ฝ”๋“œ๋ฅผ ์œ„์™€๊ฐ™์ด ์ง„ํ–‰ํ•˜๋‹ˆ,

์ด๋ฒˆ์—๋Š” merge๋กœ ์ธํ•œ ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•˜์˜€๊ณ ,
vscode์—์„œ ์ˆ˜์ •ํ•  ๋ถ€๋ถ„์„ ์„ ํƒํ•ด ์‚ญ์ œํ•˜๊ณ  merge๋ฅผ ์ง„ํ–‰ํ•˜๋‹ˆ,

๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜์™”๋‹ค.

From https://github.com/issuebombom/team_destructure_project
 * branch            main       -> FETCH_HEAD
fatal: It seems that there is already a rebase-merge directory, and
I wonder if you are in the middle of another rebase.  If that is the
case, please try
        git rebase (--continue | --abort | --skip)
If that is not the case, please
        rm -fr ".git/rebase-merge"
and run me again.  I am stopping in case you still have something
valuable there.
 

์œ„ ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๋Š” ๋ฆฌ๋ฒ ์ด์Šค(rebase) ์ž‘์—… ์ค‘์— ๋‹ค๋ฅธ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์ด ์ด๋ฏธ ์ง„ํ–‰ ์ค‘์ธ ๊ฒฝ์šฐ์— ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.

ํ•ด๊ฒฐ๋ฐฉ์•ˆ์€ ํ˜„์žฌ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์„ ์™„๋ฃŒํ•˜๊ฑฐ๋‚˜ ์ค‘๋‹จํ•˜๊ณ  ๋‹ค๋ฅธ ์ž‘์—…์„ ์ง„ํ–‰ํ•ด์•ผ ํ•œ๋‹ค.
ํ•ด์„ํ•˜์ž๋ฉด, ์ด ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๋Š” ์ด๋ฏธ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์ด ์ง„ํ–‰ ์ค‘์ธ ์ƒํƒœ์—์„œ ๋˜ ๋‹ค๋ฅธ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์„ ์‹œ๋„ํ•˜๋ ค๊ณ  ํ•  ๋•Œ ๋ฐœ์ƒ.

๋ฉ”์‹œ์ง€๋Š” ํ˜„์žฌ ์ง„ํ–‰ ์ค‘์ธ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์„ ์™„๋ฃŒํ•˜๊ฑฐ๋‚˜ ์ค‘๋‹จํ•˜๊ณ  ๋‹ค๋ฅธ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•จ์„ ๋ช…์‹œ.

์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์Œ ๋‹จ๊ณ„๋ฅผ ๋”ฐ๋ผ์•ผ ํ•œ๋‹ค.

  • ๋งŒ์•ฝ ํ˜„์žฌ ์ง„ํ–‰ ์ค‘์ธ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์„ ์™„๋ฃŒํ•˜๋ ค๋ฉด, git rebase --continue ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ช…๋ น์–ด๋Š” ํ˜„์žฌ ์ง„ํ–‰ ์ค‘์ธ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์„ ๊ณ„์†ํ•ฉ๋‹ˆ๋‹ค.
  • ๋งŒ์•ฝ ํ˜„์žฌ ์ง„ํ–‰ ์ค‘์ธ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์„ ์ค‘๋‹จํ•˜๋ ค๋ฉด, git rebase --abort ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ช…๋ น์–ด๋Š” ํ˜„์žฌ ์ง„ํ–‰ ์ค‘์ธ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์„ ์ทจ์†Œํ•˜๊ณ  ์ด์ „ ์ƒํƒœ๋กœ ๋˜๋Œ๋ฆฝ๋‹ˆ๋‹ค.
  • ํ˜„์žฌ ์ง„ํ–‰ ์ค‘์ธ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์ด ์—†๋Š”๋ฐ๋„ ์ด ์˜ค๋ฅ˜๊ฐ€ ๊ณ„์† ๋ฐœ์ƒํ•œ๋‹ค๋ฉด, .git/rebase-merge ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์‚ญ์ œํ•œ ๋‹ค์Œ ์ž‘์—…์„ ๋‹ค์‹œ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์‚ญ์ œํ•˜๊ธฐ ์œ„ํ•ด rm -fr ".git/rebase-merge" ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

 

๋‚˜๋Š” ์ฒซ๋ฒˆ์งธ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด์„œ ๊ธฐ์กด์˜ rebase ์ž‘์—…์„ ์ง„ํ–‰์‹œ์ผฐ๋‹ค.

// ์ถœ๋ ฅ๊ฐ’
Successfully rebased and updated refs/heads/mypage.
 

Successfully rebased and updated refs/heads/mypage๋Š” ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์ด ์„ฑ๊ณต์ ์œผ๋กœ ์™„๋ฃŒ๋˜์—ˆ๊ณ , refs/heads/mypage ๋ธŒ๋žœ์น˜๊ฐ€ ์—…๋ฐ์ดํŠธ๋˜์—ˆ๋‹ค๋Š” ์˜๋ฏธ์ด๋‹ค.

๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์€ ๊ธฐ์กด ์ปค๋ฐ‹๋“ค์˜ ์ˆœ์„œ๋ฅผ ๋ณ€๊ฒฝํ•˜๊ฑฐ๋‚˜ ๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ํ†ตํ•ฉํ•˜๋Š” ์ž‘์—…์ด๋‹ค.

์œ„์˜ ๋ฉ”์‹œ์ง€๋Š” ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์ด ์„ฑ๊ณต์ ์œผ๋กœ ์™„๋ฃŒ๋˜์—ˆ์œผ๋ฉฐ, refs/heads/mypage ๋ธŒ๋žœ์น˜๊ฐ€ ํ•ด๋‹น ์ž‘์—…์œผ๋กœ ์—…๋ฐ์ดํŠธ๋˜์—ˆ๋‹ค๋Š” ๊ฒƒ์„ ๋‚˜ํƒ€๋ƒ„.
๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์ด ์„ฑ๊ณต์ ์œผ๋กœ ์ˆ˜ํ–‰๋˜์–ด ์›ํ•˜๋Š” ๊ฒฐ๊ณผ๋ฅผ ์–ป์—ˆ์œผ๋ฉฐ, mypage ๋ธŒ๋žœ์น˜๊ฐ€ ๋ฆฌ๋ฒ ์ด์Šค ์ž‘์—…์˜ ์ƒˆ๋กœ์šด ์ปค๋ฐ‹์œผ๋กœ ์—…๋ฐ์ดํŠธ๋˜์—ˆ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๋ ค์ฃผ๋Š” ๋ฉ”์‹œ์ง€์ž…๋‹ˆ๋‹ค.

#git_pull_์˜ค๋ฅ˜ #git #fatal #unset_pull_ff #__rebase #pull_rebase_true_false #merge_rebase #git_hint