1

The git server I am trying to pull has a new branch . (call it branch-9)

In my local, I don't have that and I do I pull it to my local computer?

should I run this?

$git checkout -b branch-9 $git pull branch-9 

is that the right way?

2 Answers 2

3

Doing a git fetch will, if you have configured the git server as a remote, create a local tracking branch.

git fetch git checkout branch-9 # This will automatically set up to track "origin/branch-9" 

The long form of the above command is:

git fetch git checkout -b branch-9 origin/branch-9 

after you've started making local changes to your copy of branch-9, then you might want to use git pull. git pull is the same as git fetch and either git merge or git rebase (depending on your settings, defaulting to git merge).

Sign up to request clarification or add additional context in comments.

Comments

1

First get a local copy of the remote branch:

git fetch 

This will create origin/branch-9. Now check-out a branch-9:

git checkout branch-9 

This will create a new local branch that tracks the remote branch.

1 Comment

so, let's say currently i m check out in master.. So, i stay in master, and then "git fetch", and then "git checkout branch-9", right?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.