Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pull a specific branch from Github

Tags:

git

branch

github

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 ?

like image 797
Kevin ABRIOUX Avatar asked Sep 22 '17 15:09

Kevin ABRIOUX


People also ask

Can you git pull a specific branch?

You can clone a specific branch from a Git repository using the git clone –single-branch –branch command. This command retrieves all the files and metadata associated with one branch. To retrieve other branches, you'll need to fetch them later on.

How do you pull someone's remote branch?

If you want to check out a remote branch someone published, you first have to use git fetch . This command downloads the references from your remote repository to your local machine, including the reference to the remote branch. Now all you need to do is use git checkout <remote branch name> .


1 Answers

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.

like image 87
Strikegently Avatar answered Oct 09 '22 02:10

Strikegently