Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch default git branch to main #679

Closed
juhoinkinen opened this issue Mar 10, 2023 · 5 comments
Closed

Switch default git branch to main #679

juhoinkinen opened this issue Mar 10, 2023 · 5 comments
Milestone

Comments

@juhoinkinen
Copy link
Member

juhoinkinen commented Mar 10, 2023

Nowdays the default branch of a new GitHub repository is named main instead of master, and many existing projects have renamed the default branch to main.

According to GitHub documentation the basic rename process should be quite straightforward. When a branch (master) is renamed in the GitHub web UI, automation re-targets all open PRs, sets up URL redirects etc..

However, the default branch can also be changed to an existing branch. This gives the opportunity to cleanly get rid of the two erroneously pushed commits (this and this) to master and their reverts by first branching the main from master at the point before the erroneous commits. Apparently changing the default branch does not automatically retarget PRs and do other changes what renaming would do.

But as @osma suggested, lets do the rename, and just drop the erroneous commits before.

Steps:

@juhoinkinen juhoinkinen added this to the 0.61 milestone Mar 10, 2023
@juhoinkinen
Copy link
Member Author

I did locally

git reset --hard eb437a820c7140568d0d6f4fcc434925d5fe5316
git log  # double checking the reset was to correct commit
git push --force-with-lease  # before needed to switch off branch protection of master

Then renamed the default branch to main in GitHub UI, and I was shown the commands to update local clones:

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

@juhoinkinen
Copy link
Member Author

References to master updated in #680. In Wiki the master -> main redirection in links works, so there is no need updates in there.

So everything else should be working as previously, but CodeBeat analysis got confused: the checks show
image

and I cannot find a way to change the target branch in CodeBeat project/account, I think I don't have the permissions for that.

@osma
Copy link
Member

osma commented Mar 10, 2023

I had to recreate the NatLibFi/Annif project in Codebeat and delete the old one, as it wasn't possible to change the branch directly. I changed the badge in 3d44c00 so it refers to the new project.

@juhoinkinen
Copy link
Member Author

Osma changed the branch also for the Scrutinizer analysis, so now (again) everything for this seems to be done, I close this.

@juhoinkinen
Copy link
Member Author

Still one update was needed: the "latest" version of ReadTheDocs documetation was no following the new main branch before I switched the default branch (in Advanced Setttings) from ------ to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants