{"thread":{"id":"55477","subject":"How to checkout a branch (and not a tag)","startedAt":"2021-04-11T23:04:27Z","lastAt":"2021-04-11T23:29:40Z","messageCount":3,"participants":["Jeffrey Walton","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"421631","messageId":"CAH8yC8nT-68H9Vy=zxqsKeqpBqt-OJYCpVh53cm1KoeSbSVC-Q@mail.gmail.com","threadId":"55477","inReplyTo":null,"subject":"How to checkout a branch (and not a tag)","fromName":"Jeffrey Walton","fromEmail":"noloader@gmail.com","sentAt":"2021-04-11T23:04:11Z","receivedAt":"2021-04-11T23:04:27Z","isPatch":false,"sender":{"key":"noloader@gmail.com","avatar":null},"body":"I'm trying to checkout a branch called REL1_35 from\nhttps://github.com/wikimedia/mediawiki-skins-Cosmos. The repo also has\na tag called REL1_35.\n\nWhen I perform the following I apparently get the tag (with old files)\nand not the branch (with updated files):\n\n    wiki_rel=REL1_53\n    ...\n    git fetch origin && git reset --hard \"origin/${wiki_rel}\" && \\\n        git checkout -f \"${wiki_rel}\" && git pull && git clean -xdf\n\nI found https://groups.google.com/g/git-users/c/FfzGmqj6sNQ, but I am\nnot following it. My .git/config looks like it is using the proper\nreference:\n\n# cat skins/Cosmos/.git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\n[remote \"origin\"]\n        url = https://github.com/Universal-Omega/MediaWiki-Cosmos-skin.git\n        fetch = +refs/heads/*:refs/remotes/origin/*\n[branch \"REL1_35\"]\n        remote = origin\n        merge = refs/heads/REL1_35\n\nHow do I checkout the branch (and not a tag)?\n\nThanks in advance.\n"},{"id":"421632","messageId":"xmqqk0p8flui.fsf@gitster.g","threadId":"55477","inReplyTo":"CAH8yC8nT-68H9Vy=zxqsKeqpBqt-OJYCpVh53cm1KoeSbSVC-Q@mail.gmail.com","subject":"Re: How to checkout a branch (and not a tag)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-11T23:22:13Z","receivedAt":"2021-04-11T23:22:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeffrey Walton <noloader@gmail.com> writes:\n\n> I'm trying to checkout a branch called REL1_35 from\n> https://github.com/wikimedia/mediawiki-skins-Cosmos. The repo also has\n> a tag called REL1_35.\n>\n> When I perform the following I apparently get the tag (with old files)\n> and not the branch (with updated files):\n>\n>     wiki_rel=REL1_53\n\nHopefully this typo is not part of what contributed to your problem.\nAssuming that you actually used REL1_35 here...\n\n>     ...\n>     git fetch origin && git reset --hard \"origin/${wiki_rel}\" && \\\n\n...this should get their branches in refs/remotes/origin/, and would\nreset whatever local branch you are on to origin/REL1_35.  So at this\npoint, HEAD is the same as their REL1_35 branch.\n\n>         git checkout -f \"${wiki_rel}\"\n\nAnd this causes the tag/REL1_35, which was obtained from them, to be\nchecked out to a detached HEAD.\n\nWhat are you trying to do here?  Do you want your own local REL1_35\nbranch, that starts at the same commit as their REL1_35 branch?  If\nso, then instead of that \"checkout\", you would probably do\n\n\tgit checkout -b REL1_35\n\nOr whole thing up to this point would be\n\n\tgit fetch origin &&\n\tgit checkout -t -b REL1_35 origin/REL1_35\n\nand then after this, your \"git pull\" while on your REL1_35 brnch\nwould integrate with their REL1_35 branch [*]\n\n\n[Footnote]\n\n* Unless you have other funny configuration variables in the\n  repository possibly from earlier random hacking, that is.\n  Depending on the state of the repository before you started the\n  \"git fetch origin\" step, commands like \"git pull\" and \"git push\"\n  would behave differently.\n"},{"id":"421633","messageId":"CAH8yC8kZjFZo-si45oYTzUyH+J6YOLD62Bdmomzr0NDkDzLhRQ@mail.gmail.com","threadId":"55477","inReplyTo":"xmqqk0p8flui.fsf@gitster.g","subject":"Re: How to checkout a branch (and not a tag)","fromName":"Jeffrey Walton","fromEmail":"noloader@gmail.com","sentAt":"2021-04-11T23:29:25Z","receivedAt":"2021-04-11T23:29:40Z","isPatch":false,"sender":{"key":"noloader@gmail.com","avatar":null},"body":"On Sun, Apr 11, 2021 at 7:22 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Jeffrey Walton <noloader@gmail.com> writes:\n>\n> > I'm trying to checkout a branch called REL1_35 from\n> > https://github.com/wikimedia/mediawiki-skins-Cosmos. The repo also has\n> > a tag called REL1_35.\n> >\n> > When I perform the following I apparently get the tag (with old files)\n> > and not the branch (with updated files):\n> >\n> >     wiki_rel=REL1_53\n>\n> Hopefully this typo is not part of what contributed to your problem.\n> Assuming that you actually used REL1_35 here...\n\nYes, typo.\n\n> >     ...\n> >     git fetch origin && git reset --hard \"origin/${wiki_rel}\" && \\\n>\n> ...this should get their branches in refs/remotes/origin/, and would\n> reset whatever local branch you are on to origin/REL1_35.  So at this\n> point, HEAD is the same as their REL1_35 branch.\n>\n> >         git checkout -f \"${wiki_rel}\"\n>\n> And this causes the tag/REL1_35, which was obtained from them, to be\n> checked out to a detached HEAD.\n>\n> What are you trying to do here?  Do you want your own local REL1_35\n> branch, that starts at the same commit as their REL1_35 branch?\n\nI want an exact copy of the remote branch.\n\nAfter I get that copy, I usually delete unneeded fodder, like test\ngear and documentation.\n\nJeff\n"}]}