Reputation: 71
I am learning git from book, but I struggle with some problems. I have to manually clone jquery repo. Below there are my commands.
git init
git remote add origin https://github.com/jquery/jquery.git
git fetch --no-tags origin main:refs/remotes/origin/main
I don't fully understand if it that fetch command is correct. jQuery has branch main
, but after that I type following command:
git branch --set-upstream-to master origin/main
I get the following error:
fatal: branch 'origin/main' does not exist.
I don't understand why is that. How to set upstream from my local master branch to the main branch in the remote repo of jQuery?
My git version: git version 2.35.1.windows.2
Upvotes: 1
Views: 3959
Reputation: 60295
git branch --set-upstream-to master origin/main
Wrong way 'round, and --set-upstream-to
is for modifying an existing branch.
git branch -t master origin/main
aka
git branch --track master origin/main
and better might be
git checkout -b master origin/main
Easiest is just use upstream's name and git checkout main
, Git will see the unadorned branch name and fire off its convenience checking. There's no main
branch yet, so it'll look for a unique remote-tracking branch for it and find the one you set up.
$ git checkout main
branch 'main' set up to track 'origin/main'.
Switched to a new branch 'main'
Upvotes: 2