Home > Mobile >  Save git pull origin and branch
Save git pull origin and branch

Time:12-27

When I run git pull it says


There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> main

When I run git pull origin main then it works as intended. How do I make git pull automatically use origin and main?

CodePudding user response:

Just as advised by the GIT in your above image, run the following command:

git branch --set-upstream-to=origin/main main

Then try running git pull

CodePudding user response:

The easiest way to set an upstream branch is to use the --set-upstream-to option when pushing the branch to the remote repository for the first time:

$ git push --set-upstream-to=origin/<branch> 

A shorter synonym is the -u option (instead of the self-explaining but clunky --set-upstream-to=):

$ git push -u origin <branch>

If the remote counterpart branch already exists or if you want to change the upstream branch, you can use the git branch command:

$ git branch -u origin/<branch>

You can read more about upstream here: https://git-scm.com/docs/git-branch/2.19.0

  •  Tags:  
  • git
  • Related