-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fork a single sample as a new repository
This repository contains a lot of samples that were created since the inception of the SharePoint Framework.
As a result, the total size of this repository may make it cumbersome to work with.
If you'd like to fork your own copy of a single sample so you can customize it to suit your own needs, you can follow these simple steps:
-
Using your favorite command prompt, change your current directory where you'd like to clone the repository.
-
Clone the repository, by entering the following command:
git clone https://github.com/pnp/sp-dev-fx-webparts
-
Once the repository is cloned, change your current directory to the root of the SPFx Web Parts sample repo:
cd sp-dev-fx-webparts
-
Find the path to the sample you wish to extract. For these instructions, we'll use the
react-adaptivecards
, located under thesamples
folder, which means that we'll be isolatingsamples/react-adaptivecards
. -
Using the path you determined in the previous step, create a new branch from the sample's folder using this command:
git subtree split --prefix=yoursamplepath -b yoursample-name
For example, to isolate
react-adaptivecards
to a new branch with the same name, you would use:git subtree split --prefix=samples/react-adaptivecards -b react-adaptivecards
Note: This operation may take a long time.
-
While you're waiting for the previous operation to complete, you can create a new repository. This new repository is where your isolated sample will be placed. You can name the repository anything you wish. For the purpose of these instructions, we'll name the new repository
my-adaptive-cards
. -
Once the new repository is created, copy your repository's URL. The URL should look like
https://github.com/
your-github-username
/
your-new-repo-name
. For example, if you named itmy-adaptive-cards
, it will look likehttps://github.com/
your-github-username
/my-adaptive-cards
. -
Using the command line, add your new repository as a remote:
git remote add upstream https://github.com/
your-github-username
/
your-new-repo-name
For example, using
my-adaptive-cards
as your repository name:git remote add upstream https://github.com/
your-github-username
/my-adaptive-cards
-
Push your subtree using the following command:
git push upstream
yoursample-name
For example, using our sample name
react-adaptivecards
, you enter:git push upstream react-adaptivecards
-
Your new repository should now have a branch which contains only the sample folder. You can make your changes to the sample to suit your needs.