blog/content/default-branch-name.md

57 lines
1.7 KiB
Markdown
Raw Permalink Normal View History

2021-03-24 02:11:03 +00:00
---
title: 'default branch name'
2021-03-24 20:30:42 +00:00
date: 2020-06-16T15:26:29
2021-03-24 02:11:03 +00:00
tags:
- 'git'
- 'linux'
- 'dev'
---
changing gits default branch name has come up recently as an easy
action we can take to update our language and remove harmful ideas from
our daily usage.
2021-03-24 20:30:42 +00:00
<!-- more -->
2021-03-24 02:11:03 +00:00
im concerned that this effort to change the language used is ultimately
a symbolic gesture to avoid scrutiny into actual change (notably
githubs push for this change and continued contracts with ICE).
however, its an easy change to make.
lets have a look at how to change it for new repos:
mkdir -p ~/.config/git/template
echo "ref: refs/head/main" > ~/.config/git/template/HEAD
git config --global init.templateDir ~/.config/git/template
note that you can put this template dir anywhere you like.
you can also set this system-wide (not just for your user) in
/usr/share, but note that this might get overriden by package updates.
echo "ref: refs/head/main" | sudo tee /usr/share/git-core/templates/HEAD
the next time you `git init`, youll be on a branch named main.
to change an existing repo, you can use the `-m` switch of `git-branch`:
git checkout master
git branch -m master main
push with `-u` to your remote if needed and update the default branch in
the repo settings in the hosting platform of choice.
its a relatively easy change, but dont kid yourself that it makes any
real impact. go protest, [donate and sign
petitions](https://blacklivesmatter.carrd.co/), and get out there to fix
the actual problems.
## update:
as of git 2.28, theres a new configuration option and you dont need to
use the templateDir option:
git config --global init.defaultBranch main