Fatal need to specify how to reconcile divergent branches

Fatal need to specify how to reconcile divergent branches

Как бороться с этим мерзавцем? «Вытягивание без указания того, как согласовать расходящиеся ветви, не рекомендуется»

После git pull origin master я получаю следующее сообщение:

Тогда тяга была выполнена успешно. Но все же у меня есть сомнения по поводу этого сообщения.
Что лучше всего делать в этом случае?

3 ответа

Ваша ветвь, вероятно, расходится.

В режиме по умолчанию git pull является сокращением для git fetch, за которым следует git merge FETCH_HEAD.

Чтобы этого избежать, нужно

Это предупреждение было добавлено в Git 2.27, как указал Джо в своем ответе.

Вот как выглядит полное предупреждение:

Вытягивание без указания способа согласования расходящихся ветвей обескуражен. Вы можете подавить это сообщение, запустив одно из следующих команды незадолго до следующего рывка:

git config pull.rebase false # merge (стратегия по умолчанию)
git config pull.rebase true # rebase
git config pull.ff only # только быстрая перемотка вперед

Предупреждение представляет собой три команды в качестве параметров, все они подавляют предупреждение. Но они служат разным целям:

Это сохраняет поведение по умолчанию и подавляет предупреждение.

Это выполняется только в том случае, если локальная ветвь может быть перенаправлена. В противном случае он просто прерывается с сообщением об ошибке (и не создает никаких коммитов).

Но все они действительны.

Это новое предупреждение, добавлено в Git 2.27:

Это существующее поведение по умолчанию; установите это без предупреждения и без изменений в поведении; git объединит удаленную ветку с вашей локальной.

Отказаться от слияния и выхода с ненулевым статусом, если текущий HEAD уже не обновлен или слияние не может быть разрешено как ускоренная перемотка вперед

Solved «fatal: Need to specify how to reconcile divergent branches»

In this article, we will look into how to solve «fatal: Need to specify how to reconcile divergent branches» error. Last night while working on my project, I tried to pull changes from a remote branch using git pull command but instead I end up with error «fatal: Need to specify how to reconcile divergent branches». This prevented me to proceed further hence before solving this problem I decided to write an article about this so that it will help you folks as well. Check Atlassian Git tutorial to know more about the merge strategy.

Fatal need to specify how to reconcile divergent branches. Смотреть фото Fatal need to specify how to reconcile divergent branches. Смотреть картинку Fatal need to specify how to reconcile divergent branches. Картинка про Fatal need to specify how to reconcile divergent branches. Фото Fatal need to specify how to reconcile divergent branches

Solved «fatal: Need to specify how to reconcile divergent branches»

If you are working on Git system then it is not very uncommon to get this error while trying to perform git pull from your remote repository. While most of the time you will see «fatal: Need to specify how to reconcile divergent branches» as a warning but sometimes you will get it as a fatal error. If the error is showing as warning then you would still be able to pull the changes from repo but if it is showing as fatal error then you would not be allowed to proceed further.

Solution 1: Switch to Merge Strategy

When there are remote changes that are not on your local branch, they need to be resolved. The default Git behavior is merging, which will create a new commit on your local branch that resolve those changes. You can use git config pull.rebase false command to switch back to default merging strategy instead of using rebasing strategy.

After switching back to default strategy, you can again try running git pull origin main command to pull all the changes from main branch. This time you can see that all the changes are now merged by the ‘ort’ strategy. Check here more about ort strategy.

Solution 2: Switch to fast-forward Strategy

Hopefully above solution will help you solving this error. If it still doesn’t then probably it requires some more In-depth analysis. Please let me know your feedback on the comment box.

How to Merge when you get error «Hint: You have divergent branches and need to specify how to reconcile them.»

I’m working with 1 other developer who has created a branch that needs to be merged with master.

I get this error when attempting to Pull in Git in Visual Studio Community (not Visual Studio Code) to a Bitbucket repo

If I attempt to Push it says «unable to push because your local branch is behind the remote branch».

This is the error:

I’ve found various things that discuss this, eg

But none of them explain WHY this is happening and what the actions actually do.

How can I merge in what’s in the other branch into master, why is this message coming up and what effect do all the suggestions in the hints have?

Fatal need to specify how to reconcile divergent branches. Смотреть фото Fatal need to specify how to reconcile divergent branches. Смотреть картинку Fatal need to specify how to reconcile divergent branches. Картинка про Fatal need to specify how to reconcile divergent branches. Фото Fatal need to specify how to reconcile divergent branches

2 Answers 2

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

As is often the case with confusing stuff in Git, there’s some history involved.

The first thing to know is that git pull does too much stuff. Well, for some people (me), it does too much; others like that it does this much; but in fact, it does two jobs, each of which has its own separate Git command:

Assuming the first step succeeds, git pull runs a second Git command.

The reason to have a step 2 at all is simple enough: git fetch obtains new commits from some other Git repository, stuffing those new commits into your own repository where you now have access to them. But then it stops. You have access to the new commits, but nothing is actually using the new commits yet. To use the new commits, you need a second step.

There are, however, four possibilities here:

Perhaps you did no work and they did no work. You got no new commits. There’s literally nothing to do, and git merge does nothing.

Perhaps you did some work and they did nothing; you got no new commits; there’s nothing to do and git merge does nothing again.

Perhaps you did no work and they did do some work. You got some new commits. Combining your lack-of-work with their actual work is easy and git merge will take a shortcut if you allow it.

Perhaps you and they both did work. You have new commits and you got new commits from them, and git merge has to use its simple-and-stupid rules to combine the work. Git cannot take any shortcuts here and you will get a full-blown merge.

The shortcut that Git may be able to take is to simply check out their latest commit while dragging your branch name forward. The git merge command calls this a fast-forward merge, although there’s no actual merging involved. This kind of not-really-a-merge is trivial, and normally extremely safe: the only thing that can go wrong is if their latest commit doesn’t actually function properly. (In that case, you can go back to the older version that does.) So a «fast forward» merge is particularly friendly: there’s no complicated line-by-line merging rules that can go awry. Many people like this kind of «merge».

Sometimes the shortcut is not possible, and sometimes some people don’t want Git to take the shortcut (for reasons we won’t cover here to keep this answer short, or short for me anyway). There is a way to tell git merge do not take the shortcut, even if you can.

So, for git merge alone, that gives us three possibilities:

The git merge command has options to tell it what to do in all but the «nothing to do» case:

But wait, there’s more

You can fast-forward your main to match their origin/main :

And, whether or not you do that, you can merge your commit J with their commit L to produce a new merge commit M :

The git pull command can do this kind of rebasing:

This brings us to 2006 or 2008 or so

At this point in Git’s development, we have:

Time continues marching on and we reach the 2020s

1 One real-world example: I encounter some bug that’s a problem for me. I make a change to the code that I know is wrong, but lets me get my work done. I commit this horrible hack. I then wait for the upstream to make changes. They do and I bring in the new commits. If they’ve fixed the bug, I want to drop my fix, not merge or rebase it. If they have not fixed the bug, I want to rebase my hack (which may or may not need some tweaking). The «have they fixed the bug» test requires something git pull cannot test on its own.

2 Note that running git pull with arguments is not supposed to generate this kind of complaint. I still don’t run it much, so I’m not quite sure what the bug was, but in the first round or two of implementation of the new feature, there was a bug where git pull would complain inappropriately. I believe it is fixed in 2.35 and am almost positive it’s fixed in 2.36, which should be out any time now.

«You have divergent branches and need to specify how to reconcile them.» #14431

Comments

RedCheese commented Apr 21, 2022

The problem

I keep´getting this issue all of the sudden.

I read at anwsers for it to explain but i didn’t understood a single thing. I guess im not versed at Github lingo. Going to attach the screenshot for easier udnerstanding

Release version

Operating system

Steps to reproduce the behavior

Log files

Screenshots

Fatal need to specify how to reconcile divergent branches. Смотреть фото Fatal need to specify how to reconcile divergent branches. Смотреть картинку Fatal need to specify how to reconcile divergent branches. Картинка про Fatal need to specify how to reconcile divergent branches. Фото Fatal need to specify how to reconcile divergent branches

Additional context

The text was updated successfully, but these errors were encountered:

tsvetilian-ty commented Apr 21, 2022

RedCheese commented Apr 21, 2022

Sorry but i still didnt understand. Where do i input those changes in the app? is not working in the console so im confused.

carriontrooper commented Apr 22, 2022

also having this problem, how do I make those changes? There isn’t any newbie-friendly guide online, I checked.

pavelhoral commented Apr 22, 2022 •

Fatal need to specify how to reconcile divergent branches. Смотреть фото Fatal need to specify how to reconcile divergent branches. Смотреть картинку Fatal need to specify how to reconcile divergent branches. Картинка про Fatal need to specify how to reconcile divergent branches. Фото Fatal need to specify how to reconcile divergent branches

The error is pretty confusing to people that are not that familiar with git and making people go edit «some configuration file» (

/.gitconfig ) is not quite an acceptable solution (note, that if you are using purely GitHub Desktop you won’t have git CLI so average user won’t even know how to fix this).

tidy-dev commented Apr 22, 2022

We are looking at a more ideal solution for this through Desktop, but in the mean time. For those unfamiliar with using the Command Line Interface (CLI).

From GitHub Desktop, you can press Ctrl + ` (Also available from the «Repository» main menu as «Open in [Your set terminal]»). This should open up a CLI.

Now when you attempt to pull it will use that configuration and allow you to continue.

There is the possibility that because you do not use the CLI, you may need to download and install git for this to work.

Some explanation of choice above if interested:
I suggested pull.ff true simply because it attempts to fast forward your branch to be up to date with your remote before applying your local commits and if not it will preform a merge from the remote to your local branch. Read docs here. Typically when you pull a branch, add commits, and push. It is in the order assuming your local is up to date with remote. By merging when fast forwarding is not possible, you will see a merge commit informing you of how it was handled. (The other options are to rebase or always merge, many new users find rebase to be less intuitive, but really accomplishes the same thing)

lu1z5ec commented Apr 24, 2022 •

We are looking at a more ideal solution for this through Desktop, but in the mean time. For those unfamiliar with using the Command Line Interface (CLI).

There is the possibility that because you do not use the CLI, you may need to download and install git for this to work.

Some explanation of choice above if interested: I suggested pull.ff true simply because it attempts to fast forward your branch to be up to date with your remote before applying your local commits and if not it will preform a merge from the remote to your local branch. Read docs here. Typically when you pull a branch, add commits, and push. It is in the order assuming your local is up to date with remote. By merging when fast forwarding is not possible, you will see a merge commit informing you of how it was handled. (The other options are to rebase or always merge, many new users find rebase to be less intuitive, but really accomplishes the same thing)

bluetata commented Apr 24, 2022

We are looking at a more ideal solution for this through Desktop, but in the mean time. For those unfamiliar with using the Command Line Interface (CLI).

There is the possibility that because you do not use the CLI, you may need to download and install git for this to work.

Some explanation of choice above if interested: I suggested pull.ff true simply because it attempts to fast forward your branch to be up to date with your remote before applying your local commits and if not it will preform a merge from the remote to your local branch. Read docs here. Typically when you pull a branch, add commits, and push. It is in the order assuming your local is up to date with remote. By merging when fast forwarding is not possible, you will see a merge commit informing you of how it was handled. (The other options are to rebase or always merge, many new users find rebase to be less intuitive, but really accomplishes the same thing)

thank you it’s work for me!

RedCheese commented Apr 25, 2022

thank you. I think that did the trick indeed

PhilippSPOTTERON commented Apr 26, 2022

pavanhg commented Jul 25, 2022

We are looking at a more ideal solution for this through Desktop, but in the mean time. For those unfamiliar with using the Command Line Interface (CLI).

There is the possibility that because you do not use the CLI, you may need to download and install git for this to work.

Some explanation of choice above if interested: I suggested pull.ff true simply because it attempts to fast forward your branch to be up to date with your remote before applying your local commits and if not it will preform a merge from the remote to your local branch. Read docs here. Typically when you pull a branch, add commits, and push. It is in the order assuming your local is up to date with remote. By merging when fast forwarding is not possible, you will see a merge commit informing you of how it was handled. (The other options are to rebase or always merge, many new users find rebase to be less intuitive, but really accomplishes the same thing)

How can I deal with this Git warning? «Pulling without specifying how to reconcile divergent branches is discouraged»

The pull seems successful, but I am unsure.

What should I do?

Fatal need to specify how to reconcile divergent branches. Смотреть фото Fatal need to specify how to reconcile divergent branches. Смотреть картинку Fatal need to specify how to reconcile divergent branches. Картинка про Fatal need to specify how to reconcile divergent branches. Фото Fatal need to specify how to reconcile divergent branches

Fatal need to specify how to reconcile divergent branches. Смотреть фото Fatal need to specify how to reconcile divergent branches. Смотреть картинку Fatal need to specify how to reconcile divergent branches. Картинка про Fatal need to specify how to reconcile divergent branches. Фото Fatal need to specify how to reconcile divergent branches

14 Answers 14

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.

To avoid this, you need

(or not? read on to see which one fits your requirements)

This warning was added in Git 2.27.

This is what the complete warning looks like:

Pulling without specifying how to reconcile divergent branches is discouraged. You can squelch this message by running one of the following commands sometime before your next pull:

git config pull.rebase false # merge (the default strategy)
git config pull.rebase true # rebase
git config pull.ff only # fast-forward only

The warning presents three commands as options, all of these will suppress the warning. But they serve different purposes:

This keeps the default behaviour and suppresses the warning.

This only performs the pull if the local branch can be fast-forwarded. If not, it simply aborts with an error message (and does not create any commits).

Update:

Note: You may want to keep an eye on VonC’s answer here for updates on changes made to this feature in future updates.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *