Search code examples
version-controlatlassian-sourcetree

Source tree - fatal: A branch named 'main' already exists when check out


I accidentally commit my local changes to main branch.
Since there is branch protecting setting on main branch, the commit is failed to push to the remote.

But now I am 2 ahead on main.
enter image description here

When I try to checkout to the origin/main, error shows enter image description here enter image description here

How can I fix it on SourceTree?


Solution

  • Finally fix it by

    Right click on the commit in the latest origin/main > Reset current branch to this commit > Done