In git, there can be two types of branches; short-lived and long-lived:
- Short-lived branches are temporary branches that are created for a specific purpose, such as developing a new feature or fixing a bug;
- Long-lived branches exist for a longer time, such as for the duration of the project.
The following table shows a quick summary of the differences between the two:
| Short-lived Branch | Long-lived Branch | |
|---|---|---|
| Purpose: | Created for a specific feature or issue. | Serves as the primary branch for the project. |
| Example: | feature branches, bug-fix branches, etc. | main branch, develop branch, etc. |
| Creation: | Typically created from a long-lived branch. | Typically created from a specific starting point, which is often the most stable and up-to-date version of the project's codebase. |
| Management: | Can be created and merged by individual contributors. | Typically managed by a project maintainer or team. |
| Duration: | Short-lived and usually deleted once merged. | Long-lived and rarely deleted. |
| Stability: | May not always be in a stable state. | Should always be in a stable state. |
| Updates: | May have more frequent commits and pushes. | Commits and pushes may be less frequent. |
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.