Skip to content

Instantly share code, notes, and snippets.

@ut
Last active March 15, 2024 12:36
Show Gist options
  • Select an option

  • Save ut/274c6473b50cc1227da5e782885d7ab6 to your computer and use it in GitHub Desktop.

Select an option

Save ut/274c6473b50cc1227da5e782885d7ab6 to your computer and use it in GitHub Desktop.
How to get rid the old git default 'master' branch.
# how to get rid the old git default 'master' branch
# this is a variation from https://www.jumpingrivers.com/blog/git-moving-master-to-main/
# use this locally
git fetch --all # update all remotes
git checkout -b main # create new local branch main
git push --set-upstream origin main # push new branch to remote
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main # set remote main as HEAD
git branch -d master # delete local master
git branch -rd origin/master # delete remote master ref
(in moste cases that should be it and you can verify with git branch -a if on server-side everthing ist ok
# optionally: at server
git checkout master
git branch -m main
git symbolic-ref HEAD refs/heads/main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment