[GIT] fatal: Need to specify how to reconcile divergent branches.

Coastby·2022년 10월 4일
0

문제 해결

목록 보기
1/17

push가 안 됨
git pull을 하지 않고 push를 하려고 하니 아래오 같은 경고문이 보이면서 되지 않았다.
브랜치가 갈라져서 이를 해결하기 위해 아래 세개의 힌트 중 하나를 설정해달라고 한다.

Need to specity how to reconcile divergent branches. 를 검색어로 서칭을 해보았다.

Git pull desctiption

 Incorporates changes from a remote repository into the current branch. If the current branch is behind the remote, then by default it will fast-forward the current branch to
 match the remote. If the current branch and the remote have diverged, the user needs to specify how to reconcile the divergent branches with --rebase or --no-rebase (or the
 corresponding configuration option in pull.rebase).

More precisely, git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge
to reconcile diverging branches.

<repository> should be the name of a remote repository as passed to git-fetch(1). <refspec> can name an arbitrary remote ref (for example, the name of a tag) or even a
collection of refs with corresponding remote-tracking branches (e.g., refs/heads/*:refs/remotes/origin/*), but usually it is the name of a branch in the remote repository.

Default values for <repository> and <branch> are read from the "remote" and "merge" configuration for the current branch as set by git-branch(1) --track.

Assume the following history exists and the current branch is "master":

                     A---B---C master on origin
                    /
               D---E---F---G master
                   ^
                   origin/master in your repository


Then "git pull" will fetch and replay the changes from the remote master branch since it diverged from the local master (i.e., E) until its current commit (C) on top of
master and record the result in a new commit along with the names of the two parent commits and a log message from the user describing the changes.

                     A---B---C origin/master
                    /         \
               D---E---F---G---H master
See git-merge(1) for details, including how conflicts are presented and handled.

In Git 1.7.0 or later, to cancel a conflicting merge, use git reset --merge. Warning: In older versions of Git, running git pull with uncommitted changes is discouraged:
while possible, it leaves you in a state that may be hard to back out of in the case of a conflict.

If any of the remote changes overlap with local uncommitted changes, the merge will be automatically canceled and the work tree untouched. It is generally best to get any
local changes in working order before pulling or stash them away with git-stash(1).

git pull의 description에서 git pull의 기능은 현재 브랜치에 원격 저장소의 변경사항을 포함시키는 것이다.

위의 힌트대로 pull의 옵션을. 변경해 준 뒤,

git config pull.rebase false

pull을 실행하면 해결이 되었다.

git pull --no-rebase 	##default
git pull --rebase		##변경 사항을 적용할 때 병합하는 대신 리베이스합니다
git pull --ff-only		##정방향 진행이 불가능하면 중지합니다
 -r, --rebase[=false|true|merges|interactive]
 When true, rebase the current branch on top of the upstream branch after fetching. If there is a remote-tracking branch corresponding to the upstream branch and the
 upstream branch was rebased since last fetched, the rebase uses that information to avoid rebasing non-local changes.

When set to merges, rebase using git rebase --rebase-merges so that the local merge commits are included in the rebase (see git-rebase(1) for details).

When false, merge the upstream branch into the current branch.

When interactive, enable the interactive mode of rebase.

See pull.rebase, branch.<name>.rebase and branch.autoSetupRebase in git-config(1) if you want to make git pull always use --rebase instead of merging.

               Note
               This is a potentially dangerous mode of operation. It rewrites history, which does not bode well when you published that history already. Do not use this option
               unless you have read git-rebase(1) carefully.

--no-rebase
       This is shorthand for --rebase=false.
 
 
 
 
 --ff-only
	Only update to the new history if there is no divergent local history. This is the default when no method for reconciling divergent histories is provided (via the
	--rebase=* flags).

참고: https://eocoding.tistory.com/m/108

profile
훈이야 화이팅

0개의 댓글