WA
Home
Story
Experience
Framework
Insights
Testimonials
Mentorship

© 2025 Wesam Abousaid. All rights reserved.

Made with using Next.js & Tailwind CSS

Advanced Git Techniques Every Developer Should Know

Advanced Git Techniques Every Developer Should Know

June 8, 2025
2 min read
Wesam Abousaid
English
gitversion-controlproductivitydevelopmenttools

Advanced Git Techniques

Beyond basic commits and branches, Git offers powerful features that can supercharge your workflow.

1. Interactive Rebase

Clean up your commit history before merging:

git rebase -i HEAD~3

# In the editor:
pick abc123 Add feature
squash def456 Fix typo
reword ghi789 Update tests

2. Cherry-Picking

Apply specific commits from one branch to another:

# Apply a single commit
git cherry-pick abc123

# Apply multiple commits
git cherry-pick abc123..def456

3. Git Bisect

Find the commit that introduced a bug:

git bisect start
git bisect bad                 # Current commit is bad
git bisect good v1.0          # v1.0 was good

# Git will checkout commits for you to test
git bisect good  # or bad

# When done
git bisect reset

4. Stash with Style

Save work-in-progress with descriptive messages:

# Save with message
git stash save "WIP: implementing user auth"

# List all stashes
git stash list

# Apply specific stash
git stash apply stash@{2}

# Create branch from stash
git stash branch feature-auth stash@{0}

5. Reflog to the Rescue

Recover "lost" commits:

# View all reference updates
git reflog

# Restore deleted branch
git checkout -b recovered-branch abc123

6. Worktrees

Work on multiple branches simultaneously:

# Create new worktree
git worktree add ../project-hotfix hotfix-branch

# List worktrees
git worktree list

# Remove when done
git worktree remove ../project-hotfix

7. Advanced Log Queries

Find exactly what you're looking for:

# Commits by author in date range
git log --author="John" --since="2 weeks ago"

# Commits that changed specific file
git log --follow -- src/auth.js

# Search commit messages
git log --grep="bugfix"

# Pretty one-line format
git log --oneline --graph --all

8. Git Hooks

Automate tasks with hooks:

# .git/hooks/pre-commit
#!/bin/sh
npm run lint
npm test

Conclusion

These advanced Git techniques can significantly improve your development workflow. Start with one or two that solve your immediate needs, then gradually incorporate others as you become comfortable.


Back to Blog