Search code examples
gitsshbranchclone

Change Git branch on SSH remote before cloning


I am trying to clone a repo from an SSH remote like this:

git clone "ssh://[email protected]/var/www/git/www"

This works OK but using this command I am actually cloning the "master" branch of the repo, but instead I want to clone another branch which is called "dev2".

How do I achieve that?


Solution

  • after git clone.

    you can just

    git branch --track dev2 origin/dev2
    git checkout dev2

    to change your branch to dev2 easily.

    or a short cut

    git clone -b dev2 "ssh://[email protected]/var/www/git/www"