重命名本地 git 仓库,master -> main

pull 某个许久未同步的 git 仓库时,fetch 成功,但是最终报了如下错误:

$ git pull
Your configuration specifies to merge with the ref ‘refs/heads/master’
from the remote, but no such ref was fetched.

查了一会儿发现是上游把 master 分支给重命名成 main 了。于是本地仓库也需要更新:

$ git checkout master
$ git branch -m master main
$ git fetch
$ git branch –unset-upstream
$ git branch -u origin/main
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main