Git pull from specific branch

22,468

git pull is the same as git fetch followed by git merge.

To create a local branch tracking a branch on a remote, first fetch from the remote and then run git checkout with the name of a branch that matches that on the remote:

git fetch <remote>
git checkout <branch>
  • <remote> is the name of the remote, for instance origin.
  • <branch> is the name of a branch on that remote. If git branch -r shows a branch name origin/foo, Git should set this up correctly if you do git checkout foo.
Share:
22,468
user3568043
Author by

user3568043

Updated on July 09, 2022

Comments

  • user3568043
    user3568043 almost 2 years

    I want to pull changes from specified branch to my local repository, but I don't wont it to merge with master branch. What is the right way to do that? Do I have to make my own branch and than pull?

    • user229044
      user229044 about 6 years
      This is what git fetch is for.
    • IMSoP
      IMSoP about 6 years
      I think you may be muddling terminology: "pull" in git means "fetch + merge". Where do you want the changes to show up? In your working copy so you can view them? In a graph view?
    • user3568043
      user3568043 about 6 years
      @IMSoP In my working copy