Skip to contentSkip to conversation

can't commit files that have been git add'ed because "fatal: you need to resolve your current index first"

DISCUSSION Jakub Narebski 1 participant 1 message Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Please do not toppost, and try not to break quoted lines, please. Thanks in advance.

Quoted 18 lines · Bill Priest
Quoted 12 lines · --- Jakub Narebski
Quoted 9 lines · Bill Priest

I merged from one branch to another and had lots of
conflicts. I've resolved a set of files from the conflicts (in a directory) and did a git-add on this set of files. I wasn't able to commit these files. On IRC I was told that all files must be resolved before I can commit any of them. This seems pretty limiting. Why is a commit after a merge all or nothing; I thought that git figured out merges and such by the differences between files??

Quoted 4 lines

You have to resolve _conflicts_ only. The rest is
added
automatically. See git-status, git diff --merge,
git ls-files -u.

Quoted 5 lines

I understand that git requires this. My question
is git enforcing policy or is there something
"magic" about a commit after a merge. What if I want to make an independent change and check it in on the same branch before I am finished with the merge?

A little technical information about failed merge.

First, git tries to merge as mauch as it can automatically, doing tree-level merge and trying three-way file-level merge if necessary. Everything that merges cleanly is automatically added to staging area.

For each file that has unresolved conflicts git adds to staging are all (three) versions of file: original, from merged in branch, and common ancestor version, as stages 1, 2, 3 (not necessary in this order: see documentation). Additionally it leaves partially merged file in working area with RCS-like conflicts markes in it. (Note that default checking before commits refuses to check in file with conflict markers; see documentation how to force commit anyway).

Additionally git records the fact that it is in the midle of merge by recording branch(es) merged in in .git/MERGE_HEAD.

To resolve conflicts you have to bring file to some version, removing conflict markers, add this version using "git add", then commit.

You can try to git-stash partially done merge; if it doesn't work send us bugreport.

Signature · 2 lines
Jakub Narebski
Poland