Skip to content
Advanced Git Techniques

Summary - Advanced Git Techniques

Rebase

Purpose: Moves or combines commits to create a cleaner, linear commit history.
Steps:
Checkout the branch: git checkout feature-branch
Start rebase: git rebase main
Resolve conflicts: Fix and stage changes, then continue: git add <file> and git rebase --continue
Force push if needed: git push --force
Benefits: Linear history, easier bug tracking.
Caution: Avoid rebasing shared branches as it rewrites history.

Cherry-Picking

Purpose: Apply changes from specific commits to another branch without merging the entire branch.
Steps:
Identify commit hash.
Checkout target branch: git checkout target-branch
Cherry-pick commit: git cherry-pick <commit-hash>
Resolve conflicts: Fix and stage changes, then continue: git add <file> and git cherry-pick --continue
Benefits: Selective changes, useful for hotfixes.
Caution: Ensure commits don't depend on other non-picked commits.

Git Workflows

Feature Branch Workflow

Usage: Ideal for small teams.
Process: Develop features in separate branches, use PRs for review, test, then merge to master.
Benefits: Stable main branch, parallel development, reduced conflict risk.
Challenges: Merge conflicts, coordination, integration, and testing overload in large teams.

Gitflow Workflow

Usage: Suited for large teams and complex projects.
Main Branches:
Master: Stable, production-ready.
Pre-Production: Integrates and tests new features.
Supporting Branches:
Feature Branches: For new features.
Hotfix Branches: For urgent fixes.
Process: Develop in feature branches from pre-production, regularly merge, test, and finally merge into master. Use hotfix branches for urgent issues, merging fixes into both master and pre-production.
Learning advanced Git techniques and workflows will enhance your Git skills. For more detailed information, refer to the Notion link: .
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.