24

There is this repo :

https://github.com/googlesamples/android-architecture

And there is this branch :

https://github.com/googlesamples/android-architecture/tree/todo-mvvm-databinding/

I have clone the project but i have only the master. What can i do to get this branch ?

4 Answers 4

56

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.

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

Comments

5

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.

1 Comment

you can use git fetch origin todo-mvvm-databinding
5

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 

Comments

2

If the branch you want to retrieve does not exist locally but is present on the remote.

Create a branch with exactly the same name as your local remote branch

git checkout name_remote_branch 

Make a pull on this new branch

git pull 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.