Fix push to remote error when local tag has the same name as the branch

Fixes issues #1543 and #1551