-
Notifications
You must be signed in to change notification settings - Fork 144
Changing the git default branch to main
This is just a scratchpad for now to hold the experiences of those who have made this transition
-
https://github.com/ansible/community/wiki/Changing-the-git-default-branch-to-main
- @abadger Verified and integrated into the instructions below
-
https://twitter.com/xunit/status/1269881005877256192
- @abadger Verified and integrated into the instructions below
-
https://github.com/abadger/antsibull/pull/1
- @abadger Verified and integrated into the instructions below
Please update this section with any tested steps that are either simpler or handle more cornercases
Create the new branch and push it to github:
git clone [email protected]:organization/repo
cd repo
git branch -m master main # Move the master branch to the main branch locally
git push -u origin main # Set the origin to track upstream's main branch
Once this is done, the clone in repo will have the main branch. Other local clones will need to use git
In the GitHub settings:
- Go to github settings and set the default branch to main
- Github instructions on changing the default branch.
- Go to github settings and change any branch protection rules for master to be for main instead
- Go to github and retarget the open PRs from master to main
- If there's a small number of PRs, this could be done manually. A repo with a large number of PRs will probably need to script it via: Here's the api to change pr base branches https://developer.github.com/changes/2016-08-23-change-base/
- Go to github and delete the master branch
- Update any config that references the master branch. For instance, continuous integration configuration and deployment scripts may hardcode the branch name. An example for one project: https://github.com/ansible-community/antsibull/pull/100
Someone please verify
If you have forked a repository on github, you need to follow the same steps as for the main project's github git repo in order to use main as well. This is less critical as you are less likely to have PRs against your fork but it still does nice things like defaults to main for the working copy when you clone a fresh local copy rather than defaulting to the obsolete and non-updated master branch.
The fresh clone you made in the Github section will now be using main but what if you have other clones (or other contributors need to sync with your changes to the canonical repository)?
git checkout master
git branch -m master main
git fetch
git branch --unset-upstream
git branch -u origin/main
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
(from https://twitter.com/xunit/status/1269881005877256192 )
This Wiki is used for quick notes, not for support or documentation.
Working groups are now in the Ansible forum
Ansible project:
Community,
Contributor Experience,
Docs,
News,
Outreach,
RelEng,
Testing
Cloud:
AWS,
Azure,
CloudStack,
Container,
DigitalOcean,
Docker,
hcloud,
Kubernetes,
Linode,
OpenStack,
oVirt,
Virt,
VMware
Networking:
ACI,
AVI,
F5,
Meraki,
Network,
NXOS
Ansible Developer Tools:
Ansible-developer-tools
Software:
Crypto,
Foreman,
GDrive,
GitLab,
Grafana,
IPA,
JBoss,
MongoDB,
MySQL,
PostgreSQL,
RabbitMQ,
Zabbix
System:
AIX,
BSD,
HP-UX,
macOS,
Remote Management,
Solaris,
Windows
Security:
Security-Automation,
Lockdown
Tooling:
AWX,
Galaxy,
Molecule
Plugins:
httpapi