GitHub will soon start preferring that default branches are named main instead of master. I’d like to have my new project’s default branch named trunk. It might make sense to rename the branch for other projects too.
I tried initializing a repository with
git init --initial-branch trunk, but my version of Git doesn’t support that flag yet.
It looks like running
git branch -M trunk after the initial commit is (roughly?) equivalent.
Here’s approximately how I made the initial commit for https://github.com/grencez/fantasma:
mkdir fantasma cd fantasma git init echo "# Fantasma" > README.md git add README.md git commit -m "Add README" git branch -M trunk git remote add origin email@example.com:grencez/fantasma.git git push -u origin trunk
It’s pretty easy to rename master to trunk as well if you don’t have pull requests referencing it. I did this for https://github.com/grencez/lace:
cd lace # Create and checkout a new trunk branch. git checkout -b trunk # Push it upstream. git push firstname.lastname@example.org:grencez/lace.git trunk # Delete local master branch. git branch -d master
Then I changed the default branch to “trunk” on GitHub and deleted “master”.