How to configure gitolite to always create a default branch other than `master`?

25 views
Skip to first unread message

Andreas Schildbach

unread,
Sep 2, 2023, 9:27:24 AM9/2/23
to gitolite
I'd like new gitolite repos always use the `main` default branch. How do I configure this?

I've already searched the web and found tons of non-working/conflicting information.

Rod

unread,
Sep 2, 2023, 10:36:35 AM9/2/23
to Andreas Schildbach, lin feng
I would love this as well. So far the only solution I've seen involves doing pre or post commit hooks. I wish it was just baked in like Github does.

What works for me is do this when I first push...

git remote add origin git@my_server.com:my_repo.git
git push --set-upstream origin main

Anyone else that pulls needs to switch to the main branch, although some gui tools like Fork seem to be smart enough to go this automatically.

I am far from a git expert so this might not the best way to do it.

Rod

On Sat, Sep 2, 2023, at 4:42 AM, Andreas Schildbach wrote:
I'd like new gitolite repos always use the `main` default branch. How do I configure this?

I've already searched the web and found tons of non-working/conflicting information.


--
You received this message because you are subscribed to the Google Groups "gitolite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gitolite+u...@googlegroups.com.

Sitaram Chamarty

unread,
Sep 3, 2023, 1:53:22 AM9/3/23
to Rod, Andreas Schildbach, lin feng
On Sat, Sep 02, 2023 at 07:36:09AM -0700, Rod wrote:
> I would love this as well. So far the only solution I've seen involves doing pre or post commit hooks. I wish it was just baked in like Github does.

it's standard git underneath; just run `git config --global
init.defaultBranch main` on the hosting user's command line

(sure you need CLI access to the hosting user, but it's a
one-time change)

just make sure you do this *after* gitolite is installed though,
because the gitolite-admin repo expects "master"

PS: not tested; maybe someone can test it out and confirm, but I
don't see why it would not work
Reply all
Reply to author
Forward
0 new messages