0

How can I update the local repository with all new branches?

Example:

Remote: master, develop, feature1, feature2(new branch) and feature3(new branch) branches.

Local: master, develop and feature1 branches.

What I need:

Update my local and "download" all the branches

.

Lucas
  • 1,251
  • 4
  • 16
  • 34
  • If you really want to do this in one operation you will need an extension such as `git up`, which does a `git fetch` and then merges the tracking branches into your local branches. – Tim Biegeleisen May 04 '16 at 12:25

2 Answers2

1

If you want to do this with what Git ships out of the box, then you will have to checkout each local branch and do a git pull origin branch_name to update the branch:

git fetch origin         # "downloads" feature2 and feature3

git checkout master
git pull origin master
git checkout develop
git pull origin develop
git checkout feature1
git pull origin feature1

If you install git up, then you can do this with a single command:

git up

Read this SO post for more information.

Community
  • 1
  • 1
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Awesome, I'll see this git up. Thanks!! – Lucas May 04 '16 at 12:45
  • It might be worth providing a link for "git up": a google search reveals at least two Git-related projects with that name, neither of which are spelled exactly how you've spelled it. E.g. the unmaintained [git-up](https://github.com/aanand/git-up), or [GitUp](http://gitup.co/) which appears to be a Mac only GUI client. – JBentley May 04 '16 at 18:15
0

For seeing all branches(local as well as remote), You can use

git branch -a 

This command shows all branches(differentiate local and remote branches with different color). After that use git fetch command for fetching any remote branch on local

git fetch origin remote_branch_name:local_branch_name

You can change branch name at the time of fetching(just give the name what you want to local branch name). You can also able to fetch all remote branches at a time

git fetch --all

For more detail how fetch command works, please go through link

Ganesh Sagare
  • 377
  • 2
  • 12