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

Re: How to checkout a branch (and not a tag)

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 11, 2021, 23:22 UTC
Message-ID
<xmqqk0p8flui.fsf@gitster.g>
In-Reply-To
<CAH8yC8nT-68H9Vy=zxqsKeqpBqt-OJYCpVh53cm1KoeSbSVC-Q@mail.gmail.com>
Jeffrey Walton <noloader@gmail.com> writes:
Show 8 quoted lines
> 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.
Previous: Jeffrey WaltonNext: Jeffrey Walton
Message 2 of 3 in “How to checkout a branch (and not a tag)”
  1. Jeffrey WaltonApr 11, 2021
  2. Junio C HamanoApr 11, 2021
  3. Jeffrey WaltonApr 11, 2021

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.