|
|
Subscribe / Log in / New account

master/main change

master/main change

Posted Oct 21, 2025 15:40 UTC (Tue) by jhe (subscriber, #164815)
Parent article: Git considers SHA-256, Rust, LLMs, and more

How would i keep the HEAD symrefs up-to date when upstream projects change from master to main? Every time upstream deletes the branch that previously was their HEAD, all mirrors of that repo end up with a dangling symref. Current solution is doing a fresh git clone, but this is not sustainable for upstream.


to post comments

master/main change

Posted Oct 21, 2025 16:04 UTC (Tue) by NYKevin (subscriber, #129325) [Link] (2 responses)

Usually you can just git switch main and it will figure itself out (--guess is on by default).

If you have more than one remote, you can (I think) write something like git switch -t origin/main. If you have local changes, you'll have to decide what to do with them, and there are flags for that (see git-switch(1)).

master/main change

Posted Oct 21, 2025 16:24 UTC (Tue) by jhe (subscriber, #164815) [Link] (1 responses)

Thats what im doing (nano'ing the HEAD because git switch refuses to work in a bare repository) with the 1500 git mirrors. Whack-a-mole but on payroll.

master/main change

Posted Oct 21, 2025 17:11 UTC (Tue) by NYKevin (subscriber, #129325) [Link]

Don't do that. Use [1] and write a five-line bash script instead. It will save you so much time over manually nano'ing individual HEAD files one at a time.

[1]: https://git-scm.com/docs/git-symbolic-ref

main branches locally

Posted Oct 21, 2025 19:18 UTC (Tue) by josh (subscriber, #17465) [Link] (2 responses)

I almost always wish my local repositories and my github forks could avoid having a local main branch at all. My workflow is that *every* change always happens on a branch, from which I create a pull request.

So, in a local repository, I always want every new branch to start from origin/main, not main, and I never want main to point to anywhere other than origin/main. And in a remote fork, main is nothing but a stale mirror of some ancient version of the base repo, because I never push to it except by mistake (creating a pull request from my main branch because I forgot to make a local branch, which is a pain).

The only time I ever want a local main branch is for the rare project where I commit directly to main, such as private one-person repositories.

main branches locally

Posted Oct 21, 2025 21:15 UTC (Tue) by iabervon (subscriber, #722) [Link]

In your local repositories, you can just checkout origin/main and then branch -d main. It's a hassle that it creates it, but you don't need to keep it if you don't want to. (Alternatively, you can just use branch -m to turn it into the first local branch you want.)

main branches locally

Posted Oct 21, 2025 21:22 UTC (Tue) by myUser (subscriber, #58242) [Link]

> I almost always wish my local repositories and my github forks could avoid having a local main branch at all. My workflow is that *every* change always happens on a branch, from which I create a pull request.

Why then not just delete it? Yes it is created after cloning, but you can then just get rid of it for good.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds