Closed ekohl closed 11 months ago
git branch -M <new branch name>
works for me on a fresh repo without any commits. But then again, I've now got Git version 2.38.1, so maybe in (some of) the versions where the default branch name is still master
it didn't yet work?
(I'm on Linux, but I don't think that the OS should make a difference regarding this.)
My student was running Mac OS X with git 2.15 and I can confirm she couldn't rename. It may very well be that a modern git can do this.
In this link, we can find another command:
git config --global --add init.defaultBranch main
, which could work instead for older versions. So it would be a one-time thing and never had to rename the branch.
IMHO renaming master to main is not going to matter at all so I'd suggest removing it. Just change the push command to git push --set-upstream origin HEAD
and it'll use whatever branch you're on. AFAIK GitHub is smart enough to set the default branch to it so a clone from some other place will also just work.
Just confirming this is still a problem. We’re running git inside the RunCode environment suggested by the tutorial, with Ubuntu 20.04.5 LTS, and git 2.25.1. The error message is:
error: refname refs/heads/master not found
fatal: Branch rename failed
The solution is very simple – either:
git symbolic-ref HEAD refs/heads/main
instead of git branch -m main
Issue description
On https://tutorial.djangogirls.org/en/deploy/ it tells the reader to rename the branch to main if it's master (for git < 2.28). However, you can only rename it after something has been committed.
Language
It was in English, but probably applies to all.
Operating system
Mac OS X.