Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fetch only one branch of a remote Git repository?

Tags:

git

I'd like to grab a single branch (not all of them) of a remote repository and create a local tracking branch that can track further updates to that remote branch. The other branches in the remote repository are very big, so I'd like to avoid fetching them. How do I do this?

like image 233
mellis Avatar asked Jun 16 '11 08:06

mellis


People also ask

How do I fetch a single remote branch?

If you have a single remote repository, then you can omit all arguments. just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.

How do I pull just one branch in github?

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.


1 Answers

git fetch <remote_name> <branch_name> 

Worked for me.

like image 60
Abdulsattar Mohammed Avatar answered Sep 23 '22 17:09

Abdulsattar Mohammed