git/list[1] front-page[2] threads[3] people[4] search[5] about
 

strange "git clone" behavior wrt an active branch

From
LRLeo Razoumov <slonik.az@gmail.com>
Date
Sep 28, 2008, 12:05 UTC
Message-ID
<ee2a733e0809280505n69f62e0fy89667c175bcc16c@mail.gmail.com>

Hi All, I am using the latest stable version git-1.6.0.2.

The man page for git-clone states explicitly that "git clone"
" Clones a repository into a newly created directory, ...[snip]...
  and creates and checks out an initial branch equal to the
  cloned repository's currently active branch. "

I noticed that while my active branch "My" happens to point to the same commit as the "master" the git clone will check out master instead of My (currently active branch). Is it a bug?

Here is the example that demontrates the problem
~> mkdir tmp
~/tmp> git init
~/tmp> cat > txt
some text
~/tmp> git add .
~/tmp> git ci -m 'init ci'
~/tmp> git branch -a
* master
~/tmp> git co -b My
~/tmp> git branch -a
* My
  master

Now "My" is my active branch in 'tmp' repo. It points to the same commit as the master. Now let us clone it

~/tmp> cd ..
~> git clone tmp tmp1
~> cd tmp1
~/tmp1> git branch -a
* master
  origin/HEAD
  origin/My
  origin/master

In the cloned repository 'tmp1', master branch is active. No local tracking branch for "My" was created. I think this behavior contradicts the man page. Is it a bug or feature??

Thanks, --Leo--

Next: Santi Béjar
Message 1 of 4 in “strange "git clone" behavior wrt an active branch”
  1. Leo RazoumovSep 28, 2008
  2. Santi BéjarSep 28, 2008
  3. Leo RazoumovSep 28, 2008
  4. Santi BéjarSep 28, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.