Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 558
Dylan Valade Avatar asked Nov 15 '11 17:11

Dylan Valade


People also ask

What is UU in git status?

U = updated but unmerged. So UU means: unmerged, both modified.

WHAT DOES added by us mean in git?

The "added by us:" is telling you that "com/company/A. java" is new to your branch and was brought in by the branch you're rebasing against. But due to the way git implements rebase, "us" is really their branch. Not sure if this is counted as a rebase "merge conflict" unless you deleted "com/company/A.

How do I add untracked files?

The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area. We also say that they will be staged.


1 Answers

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.

like image 157
manojlds Avatar answered Oct 11 '22 22:10

manojlds