git status: what is UU and why should add/rm fix it?

Dylan Valade picture Dylan Valade · Nov 15, 2011 · Viewed 9.8k times · Source

Here is the current state of this feature branch.

Recent Steps:

  1. Remote development branch diverged
  2. Fetched remote development branch
  3. Stashed local feature branch's diverged changes that I want to keep
  4. Rebased feature branch from local development branch
  5. Stash Popped feature branch changes
  6. Stash Apply feature branch changes

Results:

$ git status
# On branch feature-foo-branch
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   foo/bar.php
#   modified:   foo/baz.php
#
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#   both modified:      foo/conflict.php
#

and status with -s

$ git status -s
UU foo/conflict.php
M  foo/bar.php
M  foo/baz/php

git recommends either add or rm to resolve the conflict. What does UU mean and why would those be the options to fix it?

All of the information I can find about resolving conflicts similar to this say not to use rm which makes me wonder why git thinks it's appropriate.

I can't find anything about UU in the git manual pages but there is this SO question which also seems to be having trouble sorting out why add would work in this case.

Answer

manojlds picture manojlds · Nov 15, 2011

See git status manual:

In the short-format, the status of each path is shown as XY PATH1 -> PATH2

For paths with merge conflicts, X and Y show the modification states of each side of the merge. For paths that do not have merge conflicts, X shows the status of the index, and Y shows the status of the work tree. For untracked paths, XY are ??

U = updated but unmerged

So UU means: unmerged, both modified

I think the add or rm message is a generic message for unmerged states, where the state can be like unmerged, both deleted, unmerged, deleted by them and so on, and hence the suggestion to rm. That is why there is as appropriate in the suggestion.