git sweep - fatal: malformed object name master

Viewed 21

For some reason, I'm no longer able to run

git sweep

as I'm getting this error

fatal: malformed object name master
fatal: branch name required

Can't seem to find anything about this particular problem online so wondered if anyone might have come across it? I changed the default branch by running this (which I'm guessing is now causing the problem)

 git config --global --add init.defaultBranch main
1 Answers

Turns out my .gitconfig file has this in it

# Clean merged branches
  sweep = !git branch --merged master | grep -v 'master$' | xargs git branch -d && git remote prune origin

Changed 'master' to 'main' and all is well.

Related