Since the v11/v12 changes, ERPNext upgrades quite weirdly – gives a bunch of messages which loop on themselves. (Thanks to @lasalesi who posted about this on the ERPNext forum)

sed -i.bak 's/\/master/\/*/g' ~/frappe-bench/apps/erpnext/.git/config
bench switch-to-branch version-12 frappe erpnext --upgrade
bench update --patch

Source: https://discuss.erpnext.com/t/updating-erpnext-from-v11-to-v12-problem/52828/6