Lucas
Lucas

Reputation: 1291

How to update the repository with all new branches

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

.

Upvotes: 0

Views: 58

Answers (2)

Ganesh Sagare
Ganesh Sagare

Reputation: 375

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

Upvotes: 0

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522762

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.

Upvotes: 1

Related Questions