remove "no master" post

It didn't end up working out, mostly because every tool ever expects a "master" branch :\
main
Brian Hicks 2020-06-04 13:50:09 -05:00
parent 104d6812c6
commit a012f62c10
1 changed files with 0 additions and 74 deletions

View File

@ -1,74 +0,0 @@
# No `master` branch
`git init` makes a `master` branch by default.
It's done this for a really long time.
But this name has some iffy connotations and sets up a weird relationship.
Is this branch my master?
Is it the master of other branches?
Why are we using a term associated with slavery?
Point is, it's got a lot of baggage which we don't need to carry forward!
But I doubt `git` will ever change the default.
Besides all the tools that have been built over the years which assume `master` as default, I'm not confident that the `git` maintainers would find the argument above particularly motivating.
So instead of forcing other people to accept my values globally, I choose to just rename the default branch `main` whenever possible.
Ideally, this gitea instance will eventually enforce that!
We can get this behavior per-repo right now with a simple git hook script (in the settings of each repo):
```bash
#!/usr/bin/env bash
set -euo pipefail
# grab command-line args
refname="${1:-}"
oldrev="${2:-}"
if [[ "${refname}" = "refs/heads/master" ]]; then
# oldrev will be all zeros for new branches
if [[ "${oldrev}" = "0000000000000000000000000000000000000000" ]]; then
echo
echo "Looks like you're trying to push a branch named 'master'. This server doesn't"
echo "accept branches named 'master'. Try another name!"
echo
echo " git branch -m master main"
echo
exit 1
else
# existing branch already named `master`
echo
echo "Warning: new git branches named 'master' will be rejected. I'm going to let this"
echo "push through since rejecting an existing branch could be really disruptive, but"
echo "please rename it soon!"
echo
echo " git branch -m master main"
echo
fi
fi
# everything looked fine here!
exit 0
```
As soon as I figure out how to set default git hooks for repos, this will be the default.
(But we will have a grace period of a month or two to get everything figured out.)
You can add this script now by going to your repo, "Settings", "Git Hooks", and setting the above script for "update".
## How to set up a new repo without `master`
Create an empty repo here, then initialize your local repo like this:
```
git init
git branch -m main
```
The first push to the new repo will set the pushed branch as default.
## How to move an existing repo away from `master`
1. move `master` to `main` (or whatever other name) with `git branch -m master main`
2. push the new branch: `git push -u origin main`
3. go to your repo, "Settings", "Branches", and change the default branch to `main`.
4. delete `master` on the branch page, or run `git push origin :master` (if the script above is active it will warn but allow you to delete the branch this way.)