Skip to content

Git Workflow

trundler-dev edited this page Mar 23, 2023 · 2 revisions

This page is meant to help you in setting up your Git workflow, so you can focus more on developing and less on the minutiae of version control.

Our workflow is intentionally kept simple to keep development flowing smoothly.

Clone the project

To clone the project, simply run the following command in your sbox/addons folder:

git clone git@github.com:apetavern/sbox-grubs.git

If you're a member of Ape Tavern, you can start writing code in main or a feature branch. Big changes should be done in a feature branch, while small changes can be committed to main while development is still in its early stages.

Adding a fork

If you are not a member of Ape Tavern, you will need to fork the project, so you can create Pull Requests from your fork to the project. Press the fork button in the top right of the repo to fork the project into your own namespace. Then, in your local git repository, run the following command:

git remote add forky git@github.com:<your_namespace>/sbox-grubs.git

If you type git remote -v and see two entries for origin, and two entries for forky, you're in good shape! You can continue to follow this guide. Make sure to push to forky as your remote when your pushing your commits up.

Workflow

To ensure you don't get your local git repository into a mess, always pull before making any changes. It's important that you're up-to-date, or you can run into a plethora of issues that will require many Google searches to resolve. Furthermore, you should always start from main. You can run the following commands to ensure you're ready to start working:

git checkout main
git pull origin main

After you've run these commands, decide if you need to make a feature branch. A feature branch should be created anytime your code will need reviewed. Your code will need to be reviewed if you are making a large amount of changes across multiple files. Eventually, all code will need to be reviewed to ensure stability of the project.

To create a new branch, you can run this git command:

git checkout -b "<branch_name>"

If I want to create a new branch for a big feature, such as the Weapon Base, I would run git checkout -b "feature/weapon-base". Now, you can start writing your code.

You can commit your changes at any point during your development process. To commit your changes, you need to add any files you have added, changed, or removed. Then, you make the commit. Once you are ready for your changes to be seen by the world, you can push to a remote.

git add .
git commit -m "My commit message"
git push <remote> <branch>

If you are working from a fork, you would use the name of your fork as the remote name, such as git push forky feature/weapon-base.

After pushing, if you realize you need to make more changes, you can make your changes, add the changes, and make a new commit. You can also squash your commits if you prefer to have one ongoing commit.

Once you are ready for review, create a Pull Request from your feature branch to apetavern/sbox-grubs:main. We will review it once we get a chance!

Clone this wiki locally