This repository follows a simple branching strategy to maintain clean and organized code development. The process ensures that each new feature is developed in its own branch and merged into the main
branch only after completion and testing.
Before starting, clone the repository to your local machine:
git clone <repository-url>
cd <repository-name>
For each feature or task, create a new branch from the main
branch. Use a meaningful name for the branch to describe the feature.
git checkout main
git pull origin main # Ensure your local main branch is up to date
git checkout -b feature/<feature-name>
Example:
git checkout -b feature/user-login
Make changes and commit them regularly to your feature branch.
git add .
git commit -m "Describe your changes briefly"
Push your feature branch to the remote repository for collaboration or backup.
git push origin feature/<feature-name>
Once the feature is complete and tested:
- Navigate to your repository on GitHub.
- Open a pull request from
feature/<feature-name>
tomain
. - Include a clear description of the feature and any testing information.
- Assign reviewers (if applicable).
After review (and approval, if applicable):
- Merge the pull request into the
main
branch. - Delete the feature branch both locally and remotely.
After merging the feature branch, delete it from your local repository to keep it clean.
git branch -d feature/<feature-name>
Always ensure your local main
branch is up to date:
git checkout main
git pull origin main
- Descriptive Branch Names: Use clear, descriptive names for feature branches, e.g.,
feature/user-authentication
. - Small Commits: Make small, meaningful commits with descriptive messages.
- Test Thoroughly: Test your feature locally before creating a pull request.
- Avoid Direct Commits to Main: All changes should go through a feature branch.
Command | Description |
---|---|
git checkout -b feature/<name> |
Create a new feature branch |
git add <file> |
Stage changes for commit |
git commit -m "message" |
Commit staged changes with a message |
git push origin feature/<name> |
Push feature branch to remote |
git branch -d feature/<name> |
Delete a local branch after merging |
git pull origin main |
Update local main branch |
# Create a new feature branch
git checkout main
git pull origin main
git checkout -b feature/add-user-profile
# Work on the feature and commit changes
git add .
git commit -m "Add profile page UI"
# Push the branch to remote
git push origin feature/add-user-profile
# After review, merge via GitHub, then:
git checkout main
git pull origin main
# Delete the feature branch locally
git branch -d feature/add-user-profile
This branching strategy ensures a smooth development process, minimizes conflicts, and keeps the main
branch production-ready.
Let me know if you'd like to make adjustments or add any specific details!