Please create a new branch for each feature. When finishing developing a feature, you need to open up a Pull Request. Before merging to main, you can add reviewers for code review. After all this, please select Rebase and Merge option to merge into main.
-
If you have not yet cloned the repo to your local machine, do it:
git clone https://github.com/zixuan-pei/we-need-a-name <local_repo_name>
cd <local_repo_name>
-
Create a PR branch:
$ git checkout -b new-branch Switched to a new branch 'new-branch'
-
Push the branch to GitHub:
$ git push origin --set-upstream new-branch Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 remote: remote: Create a pull request for 'new-branch' on GitHub by visiting: remote: https://github.com/zixuan-pei/we-need-a-name/pull/new/new-branch remote: To https://github.com/zixuan-pei/we-need-a-name * [new branch] new-branch -> new-branch Branch 'new-branch' set up to track remote branch 'new-branch' from 'origin'.
-
Commit changes on your local repo on the new branch.
-
Push your changes up to your branch:
$ git push Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 16 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 1.43 KiB | 1.43 MiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To https://github.com/zixuan-pei/we-need-a-name 623598a..0005adb new-branch -> new-branch
-
Create the PR
-
Option 1: Use the URL given when you created the branch above (step 4). In this case it would just be putting
https://github.com/zixuan-pei/we-need-a-name/pull/new/new-branch
into your browser. -
Option 2: Go to the website for the repo (https://github.com/zixuan-pei/we-need-a-name) and look for the newly-populated button allowing you to create a PR:
Click it!
-
-
Now you can assign reviewers, add a comment to the PR, and create it:
-
When everything is done and you're ready to merge the branch into main, choose Rebase and Merge option:
To make commit history clean, please reset Git base before add new commits to a PR:
-
On GitHub, switch to your branch.
-
Click Commits and find the latest commit that is not from your branch (which is the latest commit when you create your branch).
-
Copy the commit SHA.
-
Reset base to that commit:
git reset --soft <SHA>
-
Add changed files and commit new changes.
-
Finally, push the updated changes to the PR:
git push --force
pm2
is used to run the server. Here are some useful commands:
-
To list all running applications:
pm2 ls
-
To start the server (you don't really need this unless there's no running applications):
pm2 start --name <App Name> server.js
-
Delete a running application:
pm2 delete <App Name>
-
Restart an application (run it when the server has error or the code is changed):
pm2 restart <App Name>
-
To monitor logs, custom metrics, application information:
pm2 monit
The server has a /deploy
endpoint. Whenever there is a POST request sent to /deploy
, the server will fetch the latest Git commit and restart itself using pm2 restart <App Name>
.
A GitHub Webhook is set to send a POST request to the /deploy
endpoint upon new commits. You can find the webhooks in Settings -> Webhooks.