git status: what is UU and why should add/rm fix it?
-
01-03-2021 - |
문제
Here is the current state of this feature branch.
Recent Steps:
- Remote development branch diverged
- Fetched remote development branch
- Stashed local feature branch's diverged changes that I want to keep
- Rebased feature branch from local development branch
- Stash Popped feature branch changes
- 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.
해결책
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.