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

  • Home
  • SEARCH
  • 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 377653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:43:03+00:00 2026-05-12T14:43:03+00:00

How do I set a Git remote’s HEAD reference to point to something besides

  • 0

How do I set a Git remote’s HEAD reference to point to something besides “master”?

My project has a policy not to use a “master” branch (all branches are to have meaningful names). Furthermore, the canonical master repository is only accessible via ssh://, with no shell access (like GitHub or Unfuddle).

My problem is that the remote repository still has a HEAD reference to refs/heads/master, but I need it to point to a different branch. This is causing two problems:

  1. When cloning the repo, there this,

    warning: remote HEAD refers to nonexistent ref, unable to checkout.

    That’s confusing and inconvenient.

  2. The web-based code browser depends on HEAD as a basis for browsing the tree. I need HEAD to point to a valid branch, then.

  • 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-12T14:43:03+00:00Added an answer on May 12, 2026 at 2:43 pm

    There was almost the same question on GitHub a year ago.

    The idea was to rename the master branch:

    git branch -m master development
    git branch -m published master
    git push -f origin master 
    

    Making master have what you want people to use, and do all other work in branches.

    (a "git-symbolic-ref HEAD refs/head/published" would not be propagated to the remote repo)

    This is similar to "How do I delete origin/master in Git".


    As said in this thread: (emphasis mine)

    "git clone" creates only a single local branch.
    To do that, it looks at the HEAD ref of the remote repo, and creates a local branch with the same name as the remote branch referenced by it.

    So to wrap that up, you have repo A and clone it:

    • HEAD references refs/heads/master and that exists
      -> you get a local branch called master, starting from origin/master

    • HEAD references refs/heads/anotherBranch and that exists
      -> you get a local branch called anotherBranch, starting from origin/anotherBranch

    • HEAD references refs/heads/master and that doesn’t exist
      -> "git clone" complains

    Not sure if there’s any way to directly modify the HEAD ref in a repo.

    (which is all besides the point of your question, I know 😉 )


    Maybe the only way would be a "publication for the poor", where you:

     $ git-symbolic-ref HEAD refs/head/published
     $ git-update-server-info
     $ rsync -az .git/* server:/local_path_to/git/myRepo.git/
    

    But that would involve write access to the server, which is not always possible.


    As I explain in "Git: Correct way to change Active Branch in a bare repository?", git remote set-head wouldn’t change anything on the remote repo.

    It would only change the remote tracking branch stored locally in your local repo, in remotes/<name>/HEAD.


    With Git 2.29 (Q4 2020), "git remote set-head(man)" that failed still said something that hints the operation went through, which was misleading.

    See commit 5a07c6c (17 Sep 2020) by Christian Schlack (cschlack).
    (Merged by Junio C Hamano — gitster — in commit 39149df, 22 Sep 2020)

    remote: don’t show success message when set-head fails

    Signed-off-by: Christian Schlack

    Suppress the message ‘origin/HEAD set to master’ in case of an error.

    $ git remote set-head origin -a
    error: Not a valid ref: refs/remotes/origin/master
    origin/HEAD set to master
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 219k
  • Answers 219k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just concatenate all those urls with a special character (delimiter)… May 12, 2026 at 11:45 pm
  • Editorial Team
    Editorial Team added an answer I don't believe so. $(".myclass") Will return a jQuery object… May 12, 2026 at 11:45 pm
  • Editorial Team
    Editorial Team added an answer Store the last-modified timestamp when the user begins editing an… May 12, 2026 at 11:45 pm

Related Questions

How do I set a Git remote's HEAD reference to point to something besides
A git clone is set up to support pushing/pulling back into the original repository.
I've recently set up cygwin, git, and gitosis on my Windows Server 2003 box
I've just finished cruising the Google search results that contain all the email rants
Ok, a few things I'm not quite sure about. For starters: I have a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.