Home > Back-end >  it return "error: The following untracked working tree files would be overwritten by merge: pac
it return "error: The following untracked working tree files would be overwritten by merge: pac

Time:08-15

I wanted to edit the previous commit comments because they were not written properly, but when I ran the command:

git rebase -i --root

no matter what state I chose (or even if I didn't change anything, all the commits stayed in the pick state)

It always returns an error like this:

$ git rebase -i --root
error: The following untracked working tree files would be overwritten by merge:
        package-lock.json
Please move or remove them before you merge.
Aborting
hint: Could not execute the todo command
hint:
hint:     pick 47377f179a6a36514f8f8ded56039160bef023aa Initial commit from Chrome Extension CLI
hint:
hint: It has been rescheduled; To edit the command before continuing, please
hint: edit the todo list first:
hint:
hint:     git rebase --edit-todo
hint:     git rebase --continue
Could not apply 47377f1... Initial commit from Chrome Extension CLI

The file mentioned package-lock.json was accidentally committed to Git by my partner in the first commit, and I added it to .gitignore to untrack it in the second commit.

In this case, I was unable to complete a rebase at all and had to force abort it.

Although I know the reason for the error, I have absolutely no idea what I should do next to avoid this error.

When I searched for a solution, the results I got were completely different from my situation.

  • Related