

I submitted a patch upstream to change that to: sudo -u git git for-each-ref -count=10 - sort=-committerdate - sort=-HEAD -format= '%(objectname) %(refname) %(subject)%00%(committer)'īut I have no idea whether it is the kind of behavior change that they’ll accept. I was able to confirm the ordering by running this on the server: sudo -u git git for-each-ref -count=10 - sort=-committerdate -format= '%(objectname) %(refname) %(subject)%00%(committer)' '-format=%(objectname) %(refname) return It is using -sort=-committerdate in its git_get_heads_list() function as seen here: open my $fd, '-|', git_cmd(), 'for-each-ref',

At the time I write this, it’s currently showing this order for my dotfiles repo: I looked into the source code for gitweb to see how it figures out which order to display the branch heads in the UI.
#Git rename branch main update
Set the default branch to main in GitHub, GitLab, and BitBucket.Īdditionally, on, it is necessary to update the HEAD so that git clone operations from it check out main instead of master: sudo -u git git symbolic-ref HEAD refs/heads/main git/hooks/pre-push that will update the local master whenever main is pushed, and a remote post-receive hook that does the analogous job on, where I am running my own git-daemon. Git config refs/heads/mainĪdd a hook to. Tweak settings to make local master track local main rather than the other way around, while local main will track the remote main on the origin: git config refs/heads/main So, as reported here, I recently "migrated" the main branch on my dotfiles repo from "master" to "main" in the following way.Ĭreate a new "main" branch locally, based on "master": git checkout -b main In particular, where there’s an existing repo, the disruption of changing branch names may be a large burden. Tools and processes have sprung up which may assume the name of the default branch. That said, Git has defaulted to master for a very long time.
#Git rename branch main manual
I haven’t used this feature, because I am not a huge fan of the idea of requiring users who have previously cloned a repo to have to take manual steps to adjust their set-up to track your upstream configuration changes. This is the direction Git and the ecosystem are headed for the long term. GitHub allows you to rename a branch and "redirect" requests from the old branch to the new one. To my knowledge, the "default for the default" is now main on most or all of them. GitHub, GitLab, BitBucket) provide options in their GUI to set the preferred default branch for newly created repositories, as well as changing it for existing repositories. Likewise, all major Git hosting platforms (eg.

For new repositories, set the Git faultBranch to "main", overriding the Git default of "master".
