git "deleted by us" conflict with no way to resolve - Stack Overflow

I'm trying to rebase a branch, and it hit a conflict where a file was replaced with a symlink in t

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?

Share Improve this question asked Nov 20, 2024 at 12:53 Péter GyörökPéter Györök 3571 silver badge2 bronze badges 2
  • 2 Try putting the file name in quotes? git add "path/to/file.yml~abcdefghi" stackoverflow/questions/42174485/… – evolutionxbox Commented Nov 20, 2024 at 13:05
  • How do you want the file to be resoved? Added as file? Deleted? Added as symbolic link? Are you sure that the file name file.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 does git ls-files -s path/to tell you about the file? – j6t Commented Nov 20, 2024 at 13:27
Add a comment  | 

1 Answer 1

Reset to default -1

After 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

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信