23

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

51

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.

4

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
  • 1
    you can use git fetch origin todo-mvvm-databinding May 5 at 14:40
4

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
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.