5.8 KiB
Branching Practices and Standards for MiadTechnologies
Overview
In this repository, we use a structured branching strategy to keep our code organized, stable, and easily manageable. Our branching workflow consists of two main branches—main and dev—and feature branches created for specific work. This approach helps to streamline the development process, manage updates efficiently, and maintain code quality.
Branch Structure
1. main Branch
- The
mainbranch is the production-ready branch. Only stable and tested code should be merged here. - All code on
mainis reviewed and approved before merging. - Only authorized personnel (project maintainers) can merge code into
main.
2. dev Branch
- The
devbranch is for testing new features, bug fixes, and other updates before they go tomain. - Code pushed to
devshould come through pull requests from feature branches and is reviewed before merging. - All developers push their work to
devvia feature branches.
3. Ad-hoc Branches
- Each new feature, bug fix, or task gets its own branch off
dev. - Ad-hoc branches should be named according to the work they address, and/or the dir or file name or path (e.g.,
DataCollection-NewScraper,bugfix-button, ordocs-readme). - Once completed, the feature branch is merged back into
devthrough a pull request, then reviewed, and tested. - Ad-hoc branches can be nested, and should be when doing work on complex code sets. For instance, when doing work in dev, and working on DataCollection, you should branch into DataCollection to do all the work specific to that functionality. Knowing that DataCollection can be a complex branch in of itself, one can further branch into a properly named branch to match the work they address (e.g
git check dev(Main Development Branch), thengit checkout DataCollection dev(Known branch off dev), thengit checkout -b {functionality} DataCollection(new branch to address new changes branched off DataCollection branch))
Workflow for Contributors
Step 0: If You Do Not Have The Repository - Clone The Repository
Start by cloning the repository to your local machine:
git clone git@github.com:MiadTechnologiesLCC/MidasTechnologies.git
cd MidasTechnologies
Note if you're new, or not a known contributor this will not work. Contact admins
Step 1: Set Up Branch Tracking
Make sure you have the latest branches set up locally:
git fetch origin
Step 2: Check Out dev for New Work
Always base new work off the dev branch:
git checkout dev
git pull origin dev # Make sure your dev branch is up to date
Working with Ad-Hoc Branches
Step 1: Create a New Ad-Hoc Branch
For each new task or feature, create a new branch off dev. Name your branch descriptively:
git checkout -b ad-hoc-branch-name dev
Example:
git checkout -b ad-hoc-login dev
Step 2: Make and Commit Changes
As you work on the feature, make commits regularly:
git add .
git commit -m "Descriptive commit message about the change"
Step 3: Push the Feature Branch to GitHub
When you’re ready to share your work, push the feature branch to GitHub:
git push -u origin ad-hoc-branch-name
Pull Request and Review Process
Once your feature branch is ready, follow these steps:
- Create a Pull Request (PR): Go to GitHub, find your branch, and create a pull request targeting
dev. - Request a Review: Mention the team lead or project maintainer in your PR and ask for a review.
- Address Feedback: Make any requested changes by committing and pushing to your feature branch.
Once your PR is approved, it can be merged into dev.
Merging into main
Only the team lead or project maintainer will manage merging from dev to main once testing and reviews are complete. This ensures main remains stable.
The Project Maintainer currently, and author of this file is KleinPanic
Git Commands Cheat Sheet
Here’s a quick reference for Git commands relevant to our workflow:
-
Clone the repository:
git clone git@github.com:MiadTechnologiesLCC/MidasTechnologies.git -
Create a new branch:
git checkout -b branch-name dev -
Add changes:
git add . -
Commit changes:
git commit -m "Your message here" -
Push a branch to GitHub:
git push -u origin branch-name -
Switch branches:
git checkout branch-name -
Fetch updates from GitHub:
git fetch origin -
Pull updates from a branch:
git pull origin branch-name -
Delete a branch (locally):
git branch -d branch-name -
Delete a branch (remotely):
git push origin --delete branch-name
Example Workflow
Here’s an example of a typical workflow for a new feature:
-
Switch to
devand ensure it’s up to date:git checkout dev git pull origin dev -
Create a new branch:
git checkout -b feature-user-profile dev -
Work on the feature, adding and committing changes as you go.
-
Push your branch to GitHub:
git push -u origin feature-user-profile -
Create a pull request from your branch to
devon GitHub, request a review, and wait for approval.
Summary
main: Production-ready, stable code only.dev: Testing branch; pull requests from feature branches go here.- Feature Branches: Branch off
devfor specific features or bug fixes.
Following this workflow will ensure our codebase remains organized and stable while allowing for efficient development and collaboration.
Contact Admins with questions.