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

Repo management: switch default branch to main? #113

Closed
florisvdh opened this issue Nov 24, 2022 · 11 comments · Fixed by #114
Closed

Repo management: switch default branch to main? #113

florisvdh opened this issue Nov 24, 2022 · 11 comments · Fixed by #114

Comments

@florisvdh
Copy link
Member

florisvdh commented Nov 24, 2022

Hi @paleolimbot, would you agree we best migrate to main as new default branch?

I pushed main and propose one extra commit there, in order to adjust the repo's contents:

$ git log --oneline -n 2
fc23b9c (HEAD -> main, origin/main) Switch default branch from master to main
96c77b7 (origin/master, origin/HEAD, master) Merge pull request #112 from paleolimbot/tests

OBSOLETE See diff between master and main: https://github.com/paleolimbot/qgisprocess/compare/master..main.

If that's OK, then all that's needed is that you switch the default branch in the repo settings. After that, master can be push --deleted.

I can post a few git commands here to help contributors follow the migration locally.

@paleolimbot
Copy link
Collaborator

I'm game!

@paleolimbot
Copy link
Collaborator

Feel free to post the commands, although I tend to just re-fork when I run into this problem 🙂

@florisvdh
Copy link
Member Author

That's a good alternative too, people are free to choose!

@florisvdh
Copy link
Member Author

To avoid misunderstanding: the 'git commands' are applicable after the default branch in GitHub has switched. So I'll wait a little.

@florisvdh
Copy link
Member Author

florisvdh commented Nov 24, 2022

Posting the git commands already – applicable only after Dewey has flipped the default branch to main (check what https://github.com/paleolimbot/qgisprocess shows as branch to know).

Below is just one of several possible approaches to do it with git, just renaming the master branch and updating the tracking relationship.

For direct contributors to this repo

git fetch --prune
git checkout master
git branch -m main
git branch -u origin/main # supposing origin is the name in use
git pull # makes main up to date with remote

For contributors using a fork

Easiest is to just make a new fork, but alternatively I expect it to work with below commands.

The commands suppose that the fork is referred as origin, e.g. this could be the setup:

$ git remote -v
origin	[email protected]:<username>/qgisprocess.git (fetch)
origin	[email protected]:<username>/qgisprocess.git (push)
upstream	[email protected]:paleolimbot/qgisprocess.git (fetch)
upstream	[email protected]:paleolimbot/qgisprocess.git (push)

Do:

git checkout master
git pull origin master
git branch -m main
git push -u origin main

Next switch GitHub's default branch in your existing fork and then:

git fetch origin --prune
git push --delete origin master

@florisvdh
Copy link
Member Author

I'm game!

@paleolimbot since I don't have access to this setting, can you switch the default branch in GitHub? See steps in https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/changing-the-default-branch.

@paleolimbot
Copy link
Collaborator

I'll probably do it this way: https://www.tidyverse.org/blog/2021/10/renaming-default-branch/#how-to-rename-default-branch-in-your-own-existing-repos

(but you're right, it probably has to be me!)

@florisvdh
Copy link
Member Author

👍 that probably uses the GH api to do the same. But of course permission policy will always rule.

@florisvdh
Copy link
Member Author

florisvdh commented Nov 25, 2022

After reading the docs of these functions, I expect they can't do exactly what is best here; i.e. designating the already prepared main branch as default, which has the extra commit to update files that previously pointed at master. They just convert master to main. So expect some side effects or blocking to be solved.

@paleolimbot
Copy link
Collaborator

Could you delete the existing main branch then?

@florisvdh
Copy link
Member Author

OK, done (actually: renamed it to updates_for_main). Will add that branch in a draft PR.

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

Successfully merging a pull request may close this issue.

2 participants