Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pulling code from remote git branch, when it does not exist locally

Tags:

git

When branch B does not exist locally, but is on the remote repo,

git branch
 * A

git branch -a
 * A
  remotes/origin/B

How can i pull B to my local repo? Should i git checkout B first? Should i pull, while on branch A?

Please help me clarify

like image 246
James Raitsev Avatar asked Jan 12 '12 15:01

James Raitsev


People also ask

How do I pull changes from a remote branch to a local branch?

In order to fetch these changes from your remote, or in other words, download the changes to your local branch, you will perform a Git pull. Under the covers, a Git pull is actually a Git fetch followed by a Git merge. Git pull is just a shortcut to perform both of these actions in one step.

Does git pull pull all remote branches?

git fetch --all and git pull -all will only track the remote branches and track local branches that track remote branches respectively. Run this command only if there are remote branches on the server which are untracked by your local branches. Thus, you can fetch all git branches.

Can I delete local branch and pull it from remote?

Deleting a branch LOCALLY The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet.


1 Answers

If the local branch b does not exist, then git pull and then simply git checkout b and the branch will be created automatically. Other options would include a git fetch origin/b

like image 65
c00kiemon5ter Avatar answered Oct 05 '22 07:10

c00kiemon5ter