Branches
Branches are copies of the main project where you can make changes without affecting the production project until you’re ready to integrate the changes. They allow developers to work on new features, bug fixes, or experiment in isolation. When the changes are complete and reviewed, you merge the branch back into the main project.
Examples:
- Feature branches: Used for developing new features. For example, if you’re adding a login page to a website, you would create a feature branch like
feature/login-page
to make all the necessary changes. - Bugfix branches: Created to fix specific bugs. For instance, if there’s an issue with the checkout process, a branch like
bugfix/checkout-error
could be used. - Release branches: Prepared when you’re close to releasing a version of the project. A release branch might be named
release/v1.0
to finalize new features before they go live. - Hotfix branches: These are for urgent fixes that need to be addressed in production immediately. An example could be
hotfix/critical-bug
to address a security vulnerability found after release.
Commit
A commit is a snapshot of the changes made to files in a branch. It records the specific modifications made at a particular point in time, so that developers can track the history of changes and revert to previous versions if necessary. A commit typically includes a message describing what was changed.
Examples:
- Initial commit: The first commit made when setting up a new project, such as
Initial commit with basic project structure
. - Feature commit: Committing changes made while adding a new feature, for example,
Added login page UI components
. - Bugfix commit: When a bug is fixed, the commit might read
Fixed broken link on contact page
.
Pull Request
A pull request (PR) is a request to merge your changes from one branch into another (usually from a feature branch into the main branch). Before submitting a PR, you need to commit changes to the development branch. Pull requests help collaborators review changes before they are merged into the main branch. They can also trigger automated tests to ensure no errors are introduced.
Examples:
- Feature PR: After completing work on a new feature branch, like
feature/login-page
, you would create a pull request to merge these changes into themain
branch. - Bugfix PR: A PR that fixes an issue, such as
bugfix/checkout-error
, to merge the fix into the main project. - Release PR: When preparing a new release, you create a pull request from a
release/v1.0
branch to merge all the changes and updates into the main production branch.