The new commit is not on a branch
Locate the failed assumption, reproduce it, then repair the cause.
What actually caused it
This failure is a history problem, not a error. The repository still has the commits, but the labels point at the wrong place or the file still contains the unresolved choice. A teammate who fetches next will build on that mistake. Read the graph before you rewrite anything else. This failure is a history problem, not a syntax error. The repository still has the commits, but the labels point at the wrong place or the file still contains the unresolved choice. A teammate who fetches next will build on that mistake. Read the graph before you rewrite anything else. The new commit is not on a branch
Minimal reproduction
Before
git commit -m "wip"
The label or the file was not what you thought.
The fix
Stop and name the commit you meant to be on. If the change is only local, move the label or finish the resolution with a new commit. If someone else already has the old history, add a new commit instead of resetting or force-pushing. Confirm the graph and the file contents before you push. Stop and name the commit you meant to be on. If the change is only local, move the label or finish the resolution with a new commit. If someone else already has the old history, add a new commit instead of resetting or force-pushing. Confirm the graph and the file contents before you push. Check the branch name and HEAD before the next commit.
After
git status
git switch main
Status shows the branch before you commit.