... it's worse than your datacenter.
Latest update: 2021-01-02
I won't discuss the whole affair, as it has been done elsewhere many times. Tutorials are everywhere to do so, yet, i had two problems:
I am quickly explaining the whole process here.
For reference; WWWSRC
is the root directory of all your public git repositories.
In my case, and according to the httpd logs, it was acceptable to do without that, but in a more popular one you want to give them a deadline.
I'll detail below how to update their cloned repo.
I strongly advise to backup your remote git repositories. I have myself lost all my remote repos while experimenting, but since i do daily backups i was hopefully able to recover quickly ;-)
The first step was to change my git frontend, and modify all the references from the master branch to the main one:
Once everything was ironed out, i had now to deal with the repositories.
From here, i should have done this out of production. In that case, you may want to copy WWWSRC to WWWSRCNEW and clone all the repos with the temporary remote for conversion. Once the conversion is done it is just about replacing WWWSRC by WWWSRCNEW.
I proceeded like this for each of my repositories.
On my remote bare git repos, i had to do this to make 'main' the default branch:
$ cd $WWWSRC/myrepo.git $ vi hooks/hooks/post-receive $ # ^ and rename all master 'branch' reference to 'main'. sed could do the job. $ git symbolic-ref HEAD refs/heads/main
The problem right now is that the remote repo has no content for the main branch, that does not exist yet. Time to feed it:
On my local repos then, i moved the branch like this:
$ git branch -m master main $ git checkout main $ git push -u origin main $ git push origin --delete master $ # and now do an empty yet informative commit to see the result: $ git commit --allow-empty -m "master branch renamed to main"
This requires git>=2.28:
$ git config --global init.defaultBranch main
Your users (and you if you did the conversion out of production) will either need to clone again repos, or update them.
While cloning again is indeed easier, here is how to convert a cloned repo:
$ git checkout master $ git branch -m master main $ git fetch $ git branch --unset-upstream $ git branch -u origin/main