Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/DevOps & cloud

Git Advanced Techniques: Beyond Push and Pull

Master advanced Git — interactive rebase, bisect for bug hunting, cherry-pick, stash, worktrees, and trunk-based development.

22 February 20261 min readDevOps & cloudاقرأ بالعربية

On this page

  1. Interactive Rebase: Clean Your History
  2. Git Bisect: Find the Bug-Introducing Commit
  3. Cherry-Pick Specific Commits
  4. Worktrees: Multiple Branches Simultaneously
  5. Useful Aliases
  6. Trunk-Based Development

Most developers use fewer than 10 Git commands regularly, yet Git offers powerful features that save hours of debugging and streamline team collaboration.

Interactive Rebase: Clean Your History

bash
git rebase -i HEAD~3

# In the editor:
pick abc1234 Add user model
squash def5678 Fix typo in user model
squash ghi9012 Add validation to user model
# Result: one clean commit instead of three

Git Bisect: Find the Bug-Introducing Commit

bash
git bisect start
git bisect bad
git bisect good v1.0.0

# Automate with a test script:
git bisect run php artisan test --filter=UserTest

Cherry-Pick Specific Commits

bash
git cherry-pick abc1234
git cherry-pick --no-commit abc1234
git cherry-pick abc1234..def5678

Worktrees: Multiple Branches Simultaneously

bash
git worktree add ../hotfix-branch hotfix/urgent-fix
git worktree list
git worktree remove ../hotfix-branch

Useful Aliases

bash
git config --global alias.lg "log --oneline --graph --decorate --all"
git config --global alias.undo "reset --soft HEAD~1"
git config --global alias.amend "commit --amend --no-edit"
git config --global alias.wip "stash push -m 'WIP' --include-untracked"

Trunk-Based Development

Top-performing teams (per DORA research) use trunk-based development: short-lived feature branches (1-2 days max), merged to main via pull request. This reduces merge conflicts and enables continuous deployment.

All articles

Keep reading

  • Docker for Developers: From Zero to Containerized Applications28 February 20261 min read
  • CI/CD Pipelines with GitHub Actions: Automate Everything22 February 20261 min read
  • Clean Code Principles: Write Code That Humans Can Read22 February 20261 min read