Renaming branches

Pipeline developers may choose to change the pipeline’s default branch from master to main for consistency with other repositories.

This guide demonstrates how to change a pipeline’s default branch from master to main.

Prerequisites

You will need the following to get started:

  • Admin privileges for the GitHub repository
    • If you don’t have permission, ask @core-team for help on Slack.
  • nf-core tools

Rename master to main

  1. Open your repository on GitHub while viewing the master branch

  2. Select Branches (located to the right of the branch dropdown menu)

  3. In the Default branch section, find master, select the three-dot menu, then choose Rename branch

  4. Rename master to main

  5. Select learn more and save the displayed instructions for contributors

  6. Select Rename branch to confirm

  7. Verify you’re now on main in the Code tab

  8. In your IDE, switch to the dev branch

  9. Run the following command to obtain the main branch locally:

    git fetch upstream
  10. Configure Git to use main as the default branch name:

    git config --global init.defaultBranch main
  11. Verify the configuration:

    git config --global init.defaultBranch
  12. While on dev, run the sync command:

    nf-core pipelines sync
  13. Create a new branch for your changes:

    git switch -c default-branch-change
  14. Merge the template changes:

    git merge TEMPLATE
    Note

    Ensure your nf-core/tools version matches the template version in your pipeline.

  15. Resolve any merge conflicts that appear

    Tip

    If it’s the ROcrate JSON file, you can accept all incoming change.

  16. Search your repository for references to master and update them to main

    Warning

    Make sure not to modify references of master in links to other repositories!

If in doubt, ask on the nf-core Slack! :::

  1. Run the linting tool to check for issues:

    nf-core pipelines lint
  2. Commit your changes:

    git add -am 'Change default branch'
  3. Push the changes to GitHub

  4. Create a pull request against dev on GitHub

  5. Request community review on Slack

  6. Merge the pull request upon approval

Update collaborator repositories

After merging the changes, notify your collaborators to update their clones and forks. They should run the following commands:

git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a

You should also update your own clones and forks using these commands.