While I was playing around with the Git flow, I received the following error:
error: Cannot delete branch <some-branch> checked out at <some-location> as I was trying to remove a local branch that I was working on. Obviously you can’t remove a branch where
HEAD is currently pointing at. And for the solution, pretty straightforward.
Step 1. Check out another branch. For instance:
git checkout main
Step 2. Pull any changes.
Step 3. Remove the local branch causing the error.
git branch -D feature1
Step 4. Optionally, delete the remote branch as well.
git push origin -d feature1