How to clone a specific git branch

If you need to copy an already existing branch into a new or seperate repository just use this command:

cd ~/projects/
git clone --single-branch --branch <branchname> <remote-repo> project1
cd project1/
git branch

It will create a repo inside of projects/project1 inside your Home folder which contains a branch called <branchname> copied from <remote-repo>. This source <remote-repo> could be a remote reference (https..) but also a local folder.

Thanx to stackoverflow 😉

Ein Gedanke zu „How to clone a specific git branch“

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.