git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeffrey Walton <noloader@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: How to checkout a branch (and not a tag)
Date: Sun, 11 Apr 2021 16:22:13 -0700	[thread overview]
Message-ID: <xmqqk0p8flui.fsf@gitster.g> (raw)
In-Reply-To: <CAH8yC8nT-68H9Vy=zxqsKeqpBqt-OJYCpVh53cm1KoeSbSVC-Q@mail.gmail.com> (Jeffrey Walton's message of "Sun, 11 Apr 2021 19:04:11 -0400")

Jeffrey Walton <noloader@gmail.com> writes:

> I'm trying to checkout a branch called REL1_35 from
> https://github.com/wikimedia/mediawiki-skins-Cosmos. The repo also has
> a tag called REL1_35.
>
> When I perform the following I apparently get the tag (with old files)
> and not the branch (with updated files):
>
>     wiki_rel=REL1_53

Hopefully this typo is not part of what contributed to your problem.
Assuming that you actually used REL1_35 here...

>     ...
>     git fetch origin && git reset --hard "origin/${wiki_rel}" && \

...this should get their branches in refs/remotes/origin/, and would
reset whatever local branch you are on to origin/REL1_35.  So at this
point, HEAD is the same as their REL1_35 branch.

>         git checkout -f "${wiki_rel}"

And this causes the tag/REL1_35, which was obtained from them, to be
checked out to a detached HEAD.

What are you trying to do here?  Do you want your own local REL1_35
branch, that starts at the same commit as their REL1_35 branch?  If
so, then instead of that "checkout", you would probably do

	git checkout -b REL1_35

Or whole thing up to this point would be

	git fetch origin &&
	git checkout -t -b REL1_35 origin/REL1_35

and then after this, your "git pull" while on your REL1_35 brnch
would integrate with their REL1_35 branch [*]


[Footnote]

* Unless you have other funny configuration variables in the
  repository possibly from earlier random hacking, that is.
  Depending on the state of the repository before you started the
  "git fetch origin" step, commands like "git pull" and "git push"
  would behave differently.

  reply	other threads:[~2021-04-11 23:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-11 23:04 How to checkout a branch (and not a tag) Jeffrey Walton
2021-04-11 23:22 ` Junio C Hamano [this message]
2021-04-11 23:29   ` Jeffrey Walton

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqk0p8flui.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=noloader@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).