2

Rename Hugo Blog Git Repo Branch From master To main

 2 years ago
source link: https://ttys3.dev/post/rename-hugo-blog-git-repo-branch-from-master-to-main/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Rename Hugo Blog Git Repo Branch From master To main

2021-03-05

:: 荒野無燈

:: Mod 2021-03-07(2270d09)

#git 

March 7, 2021

最近编译了最新版的Git, 发现init repo的时候会提示配置全局默认branch (这事儿都是由black lives matter运动搞起的)。好吧,既然能少打一个字符,就改成 main 吧。

切换 Git 分支为 main

git checkout master

git branch -m main

# 删除本地分支
git branch -d master

# 删除远程分支
git push origin --delete master

# (并不是真正想push, 只是隐式地将远程分支设置为了跟踪main)
git push origin -u main

Github 配置

在 Github repo 设置 -> Branches 里, 将默认分支设置为 main

Netlify 配置

老灯还使用了netlify 和 netlify cms, 因此这两个的分支都要配置

Netlify Build 设置里将默认分支设置成 main

Netlify CMS admin/config.yml 默认分支设置成 main , 如果这里忘记设置了,你将无法登录 Netlify CMS 后台。

backend:
  name: git-gateway
  branch: main # Branch to update (optional; defaults to master)
  squash_merges: true # beta feature

会有如下错误:

Git Gateway Error: Please ask your site administrator to reissue the Git Gateway token.

如果你打开浏览器调试工具,你会发现它还在向 master 发送 token,这肯定是不行的。因此要修正。

另外,如果还是登录不进行,清除一下 Netlify CMS admin 的 cookies 信息 和 local storage.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK