I apologize: when I write blog posts, I like to be very detailed. I tend to be very verbose.
This is a summary of my much longer GitHub cheat sheet for PnP contributions, but without all the explanations.
If you need help to get started, I suggest you read the full article.
Otherwise, enter your information below and we’ll automatically generate all the GitHub commands you need to get started on a PnP contribution.
This article will automatically change the instructions to reflect the parameters you enter below.
Variable | Value |
---|---|
Original Repository (Upstream) | |
Your GitHub username | |
Start branch name (default is main ) | |
Branch name |
From your computer, launch whatever tool you like to run Git commands. Some people like Git Bash, but I prefer Cmder or the Node.js command prompt.
Make sure that your command prompt is in the directory where you’ll want to create your local repositories. I like to use c:\github
. You can do so by typing:
cd \github
The repository you will clone will be created a directory within your current directory. To clone the repository, type the following:
git clone https://github.com/[your_github_username]/sp-dev-fx-webparts.git
It should create a directory with the same name as your repo, then should download all the files locally to that directory.
Once your local repo is created, change to the new directory by typing:
cd sp-dev-fx-webparts
To link your local repo with the original upstream repo, you’ll type the following:
git remote add upstream https://github.com/pnp/sp-dev-fx-webparts.git
Before you start making changes, you should make sure that you have the latest version from the original upstream repository by typing:
git fetch upstream
To create your branch, follow these steps:
Update your local repository with the latest changes from the upstream repository by typing the following:
git pull upstream main:my-feature
Now we’ll let your forked origin repo know about the new branch you’ve created by typing:
git push origin my-feature
Switch to the new branch you’ve created by typing the following:
git checkout my-feature
Now you’re ready to contribute!
Here are all the commands from steps 2-4. You can just copy and paste all the lines below and run them all at once.
git clone https://github.com/hugoabernier/sp-dev-fx-webparts.git
cd sp-dev-fx-webparts
git remote add upstream https://github.com/pnp/sp-dev-fx-webparts.git
git pull upstream main:my-feature
Now that you have your own branch, you can make the changes you need. Please make sure you follow the Microsoft Open Source code of conduct.
If you aren’t sure about the code of conduct, you can also check out the Code of Conduct FAQ.
Once you’re done making your changes, you’ll want to push your contributions.
You can do so by following these steps:
From the local branch folder, type:
git add .
Commit your changes by typing:
git commit -v -a -m "Initial commit"
Push your changes to your origin repository, as follows:
git push origin my-feature
Here are all the commands from this step . You can just copy and paste all the lines below and run them all at once.
git add .
git commit -v -a -m "Initial commit"
git push origin my-feature
When you’re ready, open your pull request by following these steps:
> _(DELETE THIS PARAGRAPH AFTER READING)_
, delete them.Remember that the people who review — and ultimately approve or reject — your pull request are often volunteers who are most likely bombarded with notifications from GitHub on top of their every-day jobs. Filling the template will make it easier for them to process your pull request faster.
After you’ve completed your pull request, you’ll see that its status is marked as Open
All you have to do now is to wait for your pull request to be merged.
It can take a few days, sometimes weeks before your pull request is approved. Please be patient; Most reviewers are volunteers and have a day-to-day job.
While you’re waiting, you can start a new contribution!
If you want to continue making contributions, you simply create a new branch from the original base branch. For example, if you were created the second update to your my-feature
, you could call your next branch my-next-feature
.
Enter the name of the next branch you want to create, and we’ll update the instructions for you:
Variable | Value |
---|---|
Next branch name |
To create your next branch, follow these steps:
Type the following:
git pull upstream main:my-next-feature
Push your new branch by typing:
git push origin my-next-feature
Finally, switch to your new branch by calling:
git checkout my-next-feature
Once your next branch is created, continue contributing as you did before (contribute, push your changes, submit a pull request).
Here are all the commands from this step . You can just copy and paste all the lines below and run them all at once.
git pull upstream main:my-next-feature
git push origin my-next-feature
git checkout my-next-feature
Once your pull request has been approved and merged to the main
, you can delete your branch. Do not delete your branch before it has been approved — just in case you need to make a change to your pull request before it has been approved.
Trust me on this one.
I hope that this article will make it easier for you to contribute to PnP repositories.
main
Image by Pete Linforth from Pixabay