I'm trying to rebase a branch, and it hit a conflict where a file was replaced with a symlink in the main branch. It shows this in the output:
Unmerged paths:
(use "git restore --staged <file>..." to unstage)
(use "git add/rm <file>..." as appropriate to mark resolution)
deleted by us: path/to/file.yml~abcdefghi (BRANCHNAME branch-commit-msg)
However no matter how I try, I can't get this to change to a resolved state.
I tried all of the offered options:
$ git add path/to/file.yml
No output and also no change in the git status
output
$ git add path/to/file.yml~abcdefghi
fatal: pathspec 'path/to/file.yml~abcdefghi' did not match any files
$ git restore --staged path/to/file.yml
No output and also no change in the git status
output
$ git restore --staged path/to/file.yml~abcdefghi
fatal: pathspec 'path/to/file.yml~abcdefghi' did not match any files
$ git rm path/to/file.yml
rm 'path/to/file.yml'
The file is deleted but no change in the git status
output
$ git rm path/to/file.yml~abcdefghi
fatal: pathspec 'path/to/file.yml~abcdefghi' did not match any files
After each of these options I tried git rebase --continue
. For each option I get the same error:
path/to/file.yml~abcdefghi (BRANCHNAME branch-commit-msg): needs merge
You must edit all merge conflicts and then
mark them as resolved using git add
Can I resolve this without resorting to the nuclear option of taking a new branch from main
and copying all my changes?
I'm trying to rebase a branch, and it hit a conflict where a file was replaced with a symlink in the main branch. It shows this in the output:
Unmerged paths:
(use "git restore --staged <file>..." to unstage)
(use "git add/rm <file>..." as appropriate to mark resolution)
deleted by us: path/to/file.yml~abcdefghi (BRANCHNAME branch-commit-msg)
However no matter how I try, I can't get this to change to a resolved state.
I tried all of the offered options:
$ git add path/to/file.yml
No output and also no change in the git status
output
$ git add path/to/file.yml~abcdefghi
fatal: pathspec 'path/to/file.yml~abcdefghi' did not match any files
$ git restore --staged path/to/file.yml
No output and also no change in the git status
output
$ git restore --staged path/to/file.yml~abcdefghi
fatal: pathspec 'path/to/file.yml~abcdefghi' did not match any files
$ git rm path/to/file.yml
rm 'path/to/file.yml'
The file is deleted but no change in the git status
output
$ git rm path/to/file.yml~abcdefghi
fatal: pathspec 'path/to/file.yml~abcdefghi' did not match any files
After each of these options I tried git rebase --continue
. For each option I get the same error:
path/to/file.yml~abcdefghi (BRANCHNAME branch-commit-msg): needs merge
You must edit all merge conflicts and then
mark them as resolved using git add
Can I resolve this without resorting to the nuclear option of taking a new branch from main
and copying all my changes?
1 Answer
Reset to default -1After resetting and trying again I found that actually path/to/file.yml~abcdefghi (BRANCHNAME branch-commit-msg)
was the name of a file, including the spaces and parentheses. I thought it was some kind of annotation added by git to help identify the file but it's not. In the first attempt I also somehow managed to delete the file without noticing its odd name, and therefore I didn't see it in the ls -l
output.
So the tldr is don't get confused by strange file names...
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742355337a4428316.html
git add "path/to/file.yml~abcdefghi"
stackoverflow/questions/42174485/… – evolutionxbox Commented Nov 20, 2024 at 13:05file.yml~abcdefghi
is genuine, i.e., not an artefact of some mysterious operation (perhaps even one done by Git)? Did you check the directory? Is the file actually present? What doesgit ls-files -s path/to
tell you about the file? – j6t Commented Nov 20, 2024 at 13:27