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 6225611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:52:23+00:00 2026-05-24T08:52:23+00:00

I have a remote bare repository with two branches ‘master’ and ‘testing’, where HEAD

  • 0

I have a remote bare repository with two branches ‘master’ and ‘testing’, where HEAD refers to ‘testing’.
When cloning this repository git checks out ‘master’, if ‘master’ and ‘testing’ are on the same revision (i.e. HEAD == testing == master).
Only if ‘testing’ is one (or more) commit(s) behind or ahead, git clone checks out the ‘testing’ branch on the local side.
I tried this with git 1.7.5 on Mac OS X (10.6.8).

Addendum:
I just tried the same with a non-bare repository:

mkdir A
cd A
git init
touch a
git add a
git commit -m "init repo A with a"
git checkout -b testing

now back in the root dir:

cd ..
git clone A B
cd B
git branch -v -a
* master                 28f599b init A
  remotes/origin/HEAD    -> origin/master
  remotes/origin/master  28f599b init A
  remotes/origin/testing 28f599b init A

it’s ‘master’! Back to repo A (we are still in branch ‘testing’):

cd ../A
touch b
git add b
git commit -m "add b in branch testing"

now ‘testing’ is one commit ahead ‘master’. Now let’s clone A again:

cd ..
git clone A C
cd C
git branch -a -v
* testing                23bca39 add b in branch testing
  remotes/origin/HEAD    -> origin/testing
  remotes/origin/master  28f599b init A
  remotes/origin/testing 23bca39 add b in branch testing

You can re-verify this weird behavior by going back to A, checkout ‘master’ and merge it with ‘testing’ (so that all branches have the same head). Now clone A into D and D will be checked out on master!

  • 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-24T08:52:24+00:00Added an answer on May 24, 2026 at 8:52 am

    Got an answer from the git mailing list – @Shelhamer: you’re right

    Yes, this is a known issue.

    The git protocol just sends the list of refs and the objects they point
    to. So the local clone is forced to guess which ref HEAD is pointing to.
    E.g., with something like:

    28f599b… HEAD
    1234abc… refs/heads/master
    28f599b… refs/heads/testing

    it can see that HEAD is probably “testing”. But if it sees:

    28f599b… HEAD
    28f599b… refs/heads/master
    28f599b… refs/heads/testing

    then it has to pick one arbitrarily. Our current heuristic is to prefer
    “master” over others, and otherwise pick first alphabetically. So it’s
    at least deterministic, but as you noticed, it’s not always right.

    The real solution to this would be to extend the git protocol to convey
    symbolic ref information (and then wait for both client and server to be
    upgraded). Some patches have been floated in the past, but nothing came
    of it. Maybe it’s time to resurrect them.

    As a workaround, you can use “git clone -b testing …” if you know
    ahead of time that “testing” is what you want.

    See:

    1. http://thread.gmane.org/gmane.comp.version-control.git/102039

    2. http://article.gmane.org/gmane.comp.version-control.git/113567

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

Sidebar

Related Questions

I have created a remote bare repository: cd ~ mkdir -p git/foto-fiori.git cd git/foto-fiori.git
I have a git repository with remote foo. foo is a web app, is
I'm using git for my workflow and I have a remote testing server. What
I have a local repository cloned from a bare remote repository. The following command
I have a bare repository and two working copies - one on my machine,
I currently have Git setup with a central bare repository which is accessed by
I currently have a following Git workflow local normal git repo -> remote bare
I have a remote server that hosts my subversion repository on a non-standard ssh
I have a a remote git repo and a local clone. Let's say I
I have a remote web server that I have full access to (ssh, git,

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.