alistair
alistair

Reputation: 1172

Got a confusing git error message

Got the following message which doesn't seem to be common online:

fatal: unknown style 'diff' given for 'merge.conflictstyle'

I have looked up styles for merge.conflictstyle and diff, and diff3 seem to be appropriate. I'm not sure where I can/should change this, but it's not allowing me to push any changes, as the branch is behind, because I can't pull due to the message above :(.

Upvotes: 2

Views: 2484

Answers (5)

VonC
VonC

Reputation: 1328712

Before Git 2.45 (Q2 2024), batch 13, "git checkout --conflict=bad"(man) reported a bad conflictStyle as if it were given to a configuration variable; it has been corrected to report that the command line option is bad.

See commit 5a99c1a, commit dbeaf8e, commit 135cc71, commit 412aff7, commit 7457014 (14 Mar 2024) by Phillip Wood (phillipwood).
(Merged by Junio C Hamano -- gitster -- in commit ccdc7d9, 01 Apr 2024)

checkout: cleanup --conflict= parsing

Signed-off-by: Phillip Wood

Passing an invalid conflict style name such as "--conflict=bad" gives the error message

error: unknown style 'bad' given for 'merge.conflictstyle'

which is unfortunate as it talks about a config setting rather than the option given on the command line.

This happens because the implementation calls git_xmerge_config() to set the conflict style using the value given on the command line.

Use the newly added parse_conflict_style_name() instead and pass the value down the call chain to override the config setting.
This also means we can avoid setting up a struct config_context required for calling git_xmerge_config().

The option is now parsed in a callback to avoid having to store the option name.
This is a change in behavior as now

git checkout --conflict=bad --conflict=diff3

will error out when parsing "--conflict=bad", whereas before this change it would succeed because it would only try to parse the value of the last "--conflict" option given on the command line.

You should now see:

error: unknown conflict style 'bad'.

Upvotes: 0

Vishok Shukla
Vishok Shukla

Reputation: 1

This git command should solve the issue:

git config merge.conflictstyle merge

Upvotes: 0

Shubham Jain
Shubham Jain

Reputation: 41

Run these 2 commands:

git config --global push.default upstream

git config --global merge.conflictstyle diff3

and then try to merge again, it may work now

Upvotes: 4

John Szakmeister
John Szakmeister

Reputation: 47102

According to the git config man page, diff is not an acceptable style. merge and diff3 are the only ones it recognizes. merge is the default... so perhaps, as mipadi mentioned, diff3 is the one you want.

Upvotes: 1

mipadi
mipadi

Reputation: 411192

Try running

$ git config merge.conflictstyle diff3

and see if that works.

The issue is that you have an incorrect config option. That command will change it to the correct value, diff3.

Upvotes: 9

Related Questions