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

%MINIFYHTML29e35a3e31f54967d44db47a3e9f10b943%
git clone repository_path

For example

git clone https://github.com/alpinejs/alpine

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

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

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

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
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 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.

The Secret Role of Karma in Mahabharata

The seeds of Mahabharata were sown long back Duryodhana or Dhritarashtra were born. The story of Kaurvas and Pandavas is only the second half of the cycle of Karma. So what is the first half?

The Real Super Food is free and all around you

Are you looking for some super food that can keep you healthy and strong forever? Do you want to stay free from all illness and health issues?

Latest Music Notations

Background Theme (BGM) – Mouna Ragam – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Background Theme (BGM) from the 1986 Tamil movie Mouna Ragam in Western and Indian Notations.

Dil Kya Kare Jab Kisi Se – Julie – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Dil Kya Kare Jab Kisi Se from the 1975 Hindi movie Julie in Western and Indian Notations.

Albela Sajan Aayo Re – Hum Dil De Chuke Sanam – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Albela Sajan Aayo Re from the 1999 Hindi movie Hum Dil De Chuke Sanam in Western and Indian Notations.

Chinni Chinni Aasa Chinnadaani Asa – Roja – Piano Notations

Piano, Keyboard, Violin, Flute notes, Guitar Tabs and Sheet Music of the Song Chinni Chinni Aasa Chinnadaani Asa from the 1992 Telugu movie Roja in Western and Indian Notations.
Content Protection by DMCA.com