Home Questions - Answers How to clone a git tree or branch?

How to clone a git tree or branch?

It is easy to clone a git repository to your local machine using the git clone command. But this command will fail with a fatal error if you simply try to clone a branch or a tree of the repository by using the branch or tree URL.

So first let us see the command to clone a git repository

git clone repository_path
Code language: Bash (bash)

For example

git clone https://github.com/alpinejs/alpine
Code language: Bash (bash)

However, if you try to clone its branch or tree https://github.com/alpinejs/alpine/tree/fix-ie11 using the above method, the command will fail.

git clone https://github.com/alpinejs/alpine/tree/fix-ie11
Code language: Bash (bash)

The above command will return an error message “fatal: repository ‘https://github.com/alpinejs/alpine/tree/fix-ie11/’ not found”

The trick is to use the branch flag to clone a specific branch or a tree from git repository as follows

git clone -b branch_name repository_path
Code language: Bash (bash)

So, to clone the branch fix-ie11 of the repository, instead of using the tree url use the root url and mention the branch name using the branch flag. The command hence would be

git clone -b fix-ie11 https://github.com/alpinejs/alpine
Code language: Bash (bash)

Note that we have used the master branch url of the repository and only mentioned the branch name in the -b option. Now the specific branch would be cloned to the local machine successully. Happy Gitting!

Content Protection by DMCA.com

Download HitXP Mobile App

Get it on Google Play
Gurudevhttps://www.hitxp.com
Gurudev is the developer of Gurunudi AI Platform. This is his official website where he pens his thoughts on a wide range of topics, answers queries, shares resources and tools developed by him.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

FacebookLike
InstagramFollow
PinterestFollow
RSS FeedSubscribe
Sound CloudFollow
TwitterFollow
YoutubeSubscribe

Latest Articles

The difference between Itihasa and Puranas

Documentation of ancient Indian history and the historical events of Indian civilization in the form of Itihasa and Puranas - Ramayana and Mahabharata.

Online Education should be interactive and innovative – Fun to Learn

For online education to succeed for smaller classses - it should be as interesting as cartoons. Online education cant succeed unless it is more interesting, interactive and innovative than offline schooling.

The Complete List of Dhatus – Sanskrit Root Words and their English meaning

A complete list of all dhatus (root words or verb roots) in Sanskrit dictionary and their meanings with corresponding IPA transliteration.

Sanskrit Lesson 4 – Word Creation Magic using Dhatus

Learn how easy it is to create new words in Sanskrit using root words called Dhatus. This simple process of Sanskrit grammar powers the entire language.

Latest Music Notations

Kempadavo Ella Kempadavo – Ellindalo Bandavaru – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Kempadavo Ella Kempadavo from the 1980 Kannada movie Ellindalo Bandavaru in Western and Indian Notations.

Bella Ciao – Money Heist (La casa de papel) – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Bella Ciao from the 2018 Spanish Web Series Money Heist (La casa de papel) in Western and Indian Notations.

Haule Haule – Rab Ne Banadi Jodi – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Haule Haule from the 2008 Hindi movie Rab Ne Banadi Jodi in Western and Indian Notations.

Gori Tera Gaon Bada Pyara – Chitchor – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Gori Tera Gaon Bada Pyara from the 1976 Hindi movie Chitchor in Western and Indian Notations.
Content Protection by DMCA.com