Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 952361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:52:56+00:00 2026-05-15T23:52:56+00:00

I have a bare repository that’s used as the central store for my project.

  • 0

I have a bare repository that’s used as the central store for my project. All the developers do git clone <repo> to share with it. When they do the clone, they get a checkout of the master branch (unless they do git clone -n) because repo.git/HEAD contains ref: refs/heads/master, making this the Active Branch.

The question is, how do I change the Active Branch properly? I could simply hack the repo.git/HEAD file directly, but that seems nasty and, well, hacky.

I tried doing git checkout <otherbranch> in the repo .git directory, but that failed because I wasn’t in a work tree.

I tried git update-ref HEAD refs/heads/otherbranch but that just updated refs/heads/master to be the same as refs/heads/otherbranch (okay, I did that one in a dummy repository, not my production one!)

I tried git update-ref --no-deref HEAD refs/heads/otherbranch and that almost worked. It updated the HEAD file, but it set it to the SHA1 of the commit pointed to by refs/heads/otherbranch.

I’m testing with git version 1.7.0.2.msysgit.0.

I’m guessing there’s no way to do this through git push, as allowing all and sundry to change your default branch seems a bit unsafe (!), but surely there’s a better way to do it in the repo .git directory than directly hacking the HEAD file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:52:57+00:00Added an answer on May 15, 2026 at 11:52 pm

    If you have access to the remote bare repo, this article suggests:

    git symbolic-ref HEAD refs/heads/mybranch
    

    Which will update the HEAD file in your repository so that it contains:

    ref: refs/heads/mybranch
    

    as documented in the git-symbolic-ref


    If you don’t have access to the remote repo, see my previous answer.


    Remember that a command like git remote set-head:

    • doesn’t change the default branch of the remote repo.
      It only changes a remote tracking branch stored in your local repo as refs/remotes/<name>/HEAD

    • doesn’t change HEAD itself (again, only refs/remotes/<name>/HEAD), hence the need for
      git symbolic-ref.

    So git remote set-head is not the answer here.
    git symbolic-ref HEAD is, if you have direct access to the remote repo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a central Git bare repository. When a push is made to that
I have a CENTRAL bare repository that has three developer repositories pulling and pushing
I want to have a bare git repository stored on a (windows) network share.
I have several non-bare Git repositories. There is one central Git repository (or at
I currently have Git setup with a central bare repository which is accessed by
I have a bare git-svn repository and did a 'git svn fetch' on it.
I have created a bare git repo (lets call it repo #1) and cloned
We have a bare repository on a remote server that people can connect to
I have configured git so that I can push my local dev-repository to my
I have a bare repository on my server that I push to in /var/www/repos/my_project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.