Inter 🌐 Media

  • Home
  • Blog
  • Portfolio
  • Newsletter
  • Contact

Git cloning a branch other than master from Github

February 25th, 2020

2 minute read 📗
  • Link to the Git cloning a branch other than master from Github podcast on anchorfm

Today I had to check a student’s work that resided on a branch other than master. I have always been used to just git cloning a repository’s master branch, as usually that is what we all push to Github because it is the production branch. And everything is usually merged locally. But sometimes, for whatever reason, perhaps a patch, another branch is pushed to Github, which then, if the code is acceptable, is merged into the master branch. Sometimes courses have many different branches that represent sections of the course. Those never get merged into the master branch.

Anyhoo, I wanted to download this student’s patch branch, but knew that the regular way of git cloning a Github repository was not going to work. It would just download the master branch.

I found out how to git clone a specific branch from a Github repository (which actually resides on the remote Github repository) on stackoverflow. This is what I did, and it works like a charm:

git clone <url> --branch <branch> --single-branch

And if you want to download only a specific folder from that branch, you would do:

git clone <url> --branch <branch> --single-branch [<folder>]

I went with the former. I wanted to git clone the entire branch. And that is it!

Git File Large Storage

I will be embedding this episode of Plugging in The Holes along with a transcript in the form of a post on interglobalmedianetwork.com for your hearing and reading pleasure. I will be including the related resource links mentioned in the podcast of course. Always do. Bye for now!

Related Resources

  • Download a specific branch of a github project
Tagged in: git git-clone git-branching
Categorized under: git
Discuss On Twitter Mobile
  • Facebook
  • Twitter
  • Linkedin
  • Hacker News
  • Reddit
Maria D. Campbell

Created by Maria D. Campbell who lives and works in New York City building and teaching useful things. You should follow her on Twitter.

  • ← Newer
  • Older →
  • Business Hours
  • Monday: 9:00am - 5:00pm
  • Tuesday: 9:00am - 5:00pm
  • Wednesday: 9:00am - 5:00pm
  • Thursday: 9:00am - 5:00pm
  • Friday: 9:00am - 5:00pm
  • Saturday: Closed
  • Sunday: Closed
  • And By Appointment
  • Podcast
  • Plugging In The Holes
  • Login
  • Admin Login
  • Newsletter
  • Newsletter
  • follow us on Github
  • follow us on Twitter
  • connect with us on Instagram
  • connect with us on Linkedin
ContactSitemapRSS
© 2022 Inter-Global Media Network, Inc.