git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Mike Gant <mwgant@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: git clone operation
Date: Sun, 17 Aug 2008 12:23:57 -0700 (PDT)	[thread overview]
Message-ID: <m3wsifsawl.fsf@localhost.localdomain> (raw)
In-Reply-To: <20080817184443.GA11782@mg1.gantsfort.com>

Mike Gant <mwgant@gmail.com> writes:

> I'm trying to understand git-clone and what to expect when I clone a
> repository. Disclaimer, I am a newbie :).
[...]

> According to the man page, git-clone "creates and checks out an initial
> branch equal to the cloned repository's currently active branch."
[...]

> Now, let's say that I am working in the cpu-intfc branch of the original
> repository and I clone the repository.
> 
> Running git-branch -a returns the following
> 
>   origin/HEAD
>   origin/cpu-intfc
>   origin/gige_mux
>   origin/improve-build
>   origin/main-devel
>   origin/master
> * cpu-intfc
> 
> And this,
> 
> $ cat .git/refs/remotes/origin/HEAD
> ref: refs/remotes/origin/cpu-intfc
> 
> I was expecting to have a local branch named master (that is equal to
> the remote branch origin/cpu-intfc) instead of cpu-intfc. Am I wrong to
> expect this? Also, as a newbie user, it seems odd that I cannot specify
> which branch of repo that I am cloning should be the default (master)
> branch of the cloned repo? To put it another way, when cloning a repo I
> have no way of controlling which branch I get as the default. It just
> happens to depend on which branch the developer is working in at the
> time I clone.  I've read through the man-page and there doesn't seem to
> be any way around this.

Currently the situation is a bit strange, because while git-remote
supports selecting which branch is meant to be remote-tracking master
branch via '-m <master>' option to "add" subcommand (setting
origin/HEAD symref), git-clone which is init + remote + fetch + some
bookkeeping and shortcuts doesn't.

Both commands are now built-in.

> I realize that I can create a new local branch that is based off the
> desired branch:
> 
> $ git-checkout -b master origin/master
> 
> Is this the accepted method for obtaining the desired branch?

You can use (with new anough Git)

  $ git checkout --track -b master origin/master

to setup repository in such way that "git pull" on 'master'
would know that it is meant to fetch from 'origin' and merge
'origin/master'.

In upcoming 1.6.1 it would be enough to use

  $ git checkout --track origin/master

-- 
Jakub Narebski
Poland
ShadeHawk on #git

  reply	other threads:[~2008-08-17 19:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-17 18:44 git clone operation Mike Gant
2008-08-17 19:23 ` Jakub Narebski [this message]
2008-08-17 19:38   ` Björn Steinbrink
2008-08-20  2:23     ` Mike Gant
2008-08-20  2:27       ` Mike Gant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3wsifsawl.fsf@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mwgant@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).