From 40427ca751d4999afd4bdff2c625c15d5c5ae06d Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Thu, 25 Jun 2020 11:38:05 +0200 Subject: [PATCH] Add note --- content/notes/2020/06/2020-06-25--git-main.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 content/notes/2020/06/2020-06-25--git-main.md diff --git a/content/notes/2020/06/2020-06-25--git-main.md b/content/notes/2020/06/2020-06-25--git-main.md new file mode 100644 index 0000000..abc0b87 --- /dev/null +++ b/content/notes/2020/06/2020-06-25--git-main.md @@ -0,0 +1,19 @@ +--- +title: Set default git branch to main +author: Yarmo Mackenbach +slug: git-main +date: "2020-06-25 11:37:43" +published: true +--- + +For a while, we've all been seeing the "switch git default branch from master to main" posts, the earliest I recall having been [written by Scott Hanselman](https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx). I've been postponing the change for a bit, but it was [the post by Kristófer Reykjalín](https://www.thorlaksson.com/im-changing-the-default-branch-name-in-my-git-repositories-and-you-should-too/) that gave the required motivation to go out and just do it. + +For new repositories, Gitea already has [the option to set the default branch name](https://github.com/go-gitea/gitea/pull/10803). + +For exiting repositories, the [commands provided by Scott](https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx) work perfectly: + +``` +git checkout master; git branch -m master main; git push -u origin main +``` + +As for my website, here's the [commit](https://git.yarmo.eu/yarmo/yarmo.eu/commit/78e18c55c59c8e65e99013718cd42154ddb7ebd6) that completed the transition, making sure my CI/CD solution knows what to listen to.