How to pull a specific branch from Github

The above answer works well but I wanted to post with fetch and checkout which works fine as well.

Step 1: git fetch todo-mvvm-databinding

Step 2: git checkout todo-mvvm-databinding

You are on your todo-mvvm-databinding branch.


If you did a clone, then all branches should be available to you. You need to checkout the branch.

git checkout todo-mvvm-databinding

If the branch isn't available for whatever reason, then you can create it and then pull it:

git checkout -b todo-mvvm-databinding (-b specifies "create branch")

git pull origin todo-mvvm-databinding will fetch and merge this branch into your local one.


Most of those above methods works but I would like to present this approach which worked well for me.

Step 1: List all remote branches that are available

git fetch
git branch -r

The out put may look as shown below depending on available remote branches for your project.

origin/HEAD -> origin/master
origin/develop
origin/feature/modular_approach
origin/master

Step 2:

Make sure to commit all your changes on the current branch as git will throw some errors and warning about uncommited codes. Select a branch and run this command.

git checkout origin/feature/modular_approach

Tags:

Branch

Git

Github