简体   繁体   中英

Clone a local git feature branch

We have a feature branch in VSTS - feature/someproject. I need to work on the same feature/someproject branch. Here's what I am trying in my laptop to clone the feature stream:

/c/work> mkdir test
/c/work> cd test
/c/work/test>git checkout -b feature/test feature/someproject

But I get the below error:

fatal: Not a git repository (or any of the parent directories): .git

How can I clone the feature stream locally in my laptop for some work?

you need to first clone the repo.

git clone repoAddress

Once you have the repository cloned you can checkout the feature branch.

  • If you only want to clone the feature/someproject branch to a local repo , you can follow below commands:

     git clone <VSTS git repo URL> --single-branch feature/someproject --branch feature/someproject cd feature/someproject 

    Now the local git will only contain feature/someproject branch.

  • If your work not only contribute for feature/someproject branch, but for for other branches, then you'd better clone the whole git repo and switch to different branches by git checkout . Such as:

     git clone <VSTS git repo URL> cd reponame git checkout feature/someproject 
  • And if you already cloned the VSTS git repo , you should execute git commands under the local git repo's directory (where a hidden .git folder located).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM