What Git work patterns have you used?
sobes.tech AI
Answer from AI
-
Git-flow: Used for projects with a clearly defined release cycle. Convenient for managing feature commits, bug fixes, and release preparations. Creates branches
feature,develop,release,hotfix,master. -
GitHub flow: Applied to projects where the priority is on frequent, small releases. A simple model based on a main branch (
mainormaster) and feature or fix branches that are merged into the main branch after review. -
Trunk-based development: Practiced for projects requiring high frequency of integration and continuous deployment. Developers make changes directly to the main branch (
trunk) or short-lived branches that are quickly merged back. The key element is Feature Toggles.
In addition to these main patterns, I used:
-
Rebase vs Merge: Depending on the situation and team agreements, I used
git rebaseto maintain a clean commit history within local branches before merging, andgit merge --no-ffto preserve an explicit merge history in the main branch.# Rebase example git checkout feature/nova-feature git pull --rebase origin main # Resolve conflicts if any git push -f origin feature/nova-feature # Or a pull request to merge into main# Merge --no-ff example git checkout main git merge --no-ff feature/nova-feature -m "Merge feature nova-feature into main" git push origin main -
Squash and Merge: Often used when merging feature branches into the main branch via Pull Request. It allows combining multiple commits from a feature branch into a single clean commit in the main branch.
# Example of squash merge via Git platform interface (GitHub, GitLab) # Usually performed when confirming a Pull Request. -
Cherry-picking: Used to transfer specific commits between branches, for example, to backport fixes from the main branch to a release or staging branch.
# Cherry-pick example git checkout release/v1.2 git cherry-pick <commit_hash>