🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

7 Git Tricks That Senior Developers Use Every Day

7 Git Tricks That Senior Developers Use Every Day

Git is much more powerful than most developers realize. These seven techniques are used daily by experienced developers to work more efficiently, keep clean histories, and debug problems faster.

1. Interactive Staging (git add -p)

Stage specific parts of a file instead of the entire file:

git add -p

# Git shows each change (hunk) and asks:
# y - stage this hunk
# n - skip this hunk
# s - split into smaller hunks
# e - manually edit the hunk
# q - quit

This lets you create focused, logical commits even when you have made multiple changes to one file.

2. Fixup Commits and Autosquash

Fix a previous commit without cluttering your history:

# Create a fixup commit targeting a specific commit
git commit --fixup=abc1234

# Later, rebase and auto-squash fixup commits
git rebase -i --autosquash main

# Enable autosquash by default
git config --global rebase.autosquash true

3. Git Bisect for Bug Hunting

Find the exact commit that introduced a bug using binary search:

# Start bisecting
git bisect start

# Mark current commit as bad
git bisect bad

# Mark a known good commit
git bisect good v1.0.0

# Git checks out middle commits - you test each one
# Mark each as good or bad
git bisect good  # or
git bisect bad

# When found, git tells you the exact commit
# Reset when done
git bisect reset

4. Advanced Stash Management

# Stash with a descriptive message
git stash push -m "WIP: refactoring auth module"

# Stash only specific files
git stash push -m "partial work" -- src/auth.js src/login.js

# List stashes
git stash list

# Apply a specific stash without removing it
git stash apply stash@{2}

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

5. Rewriting History Safely

# Amend the last commit (message or content)
git commit --amend --no-edit

# Interactive rebase - reorder, squash, edit commits
git rebase -i HEAD~5

# Pick, squash, reword, edit, or drop commits
# pick   abc1234 Add feature A
# squash def5678 Fix typo in feature A
# reword ghi9012 Add feature B
# drop   jkl3456 Remove debug logging

6. Git Log Power Queries

# Pretty one-line log with graph
git log --oneline --graph --all --decorate

# Search commits by message
git log --grep="fix" --oneline

# Search commits by code change
git log -S "functionName" --oneline

# Show changes by a specific author in date range
git log --author="John" --after="2026-01-01" --before="2026-03-01" --oneline

# Show files changed in each commit
git log --stat --oneline -10

7. Git Worktrees for Parallel Work

# Create a new worktree for a different branch
git worktree add ../hotfix-branch hotfix/urgent-fix

# Work in the new directory without switching branches
cd ../hotfix-branch
# Make changes, commit, push

# List worktrees
git worktree list

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

Worktrees let you work on multiple branches simultaneously without stashing or committing incomplete work.

Bonus: Useful Git Aliases

git config --global alias.lg "log --oneline --graph --all --decorate"
git config --global alias.st "status -sb"
git config --global alias.co "checkout"
git config --global alias.br "branch -v"
git config --global alias.last "log -1 HEAD --stat"
git config --global alias.unstage "reset HEAD --"

These techniques take minutes to learn but save hours over time. Start incorporating one or two into your daily workflow and gradually adopt the rest as they become natural.

Share this article:
Nico Brandt
About the Author

Nico Brandt

JavaScript Development, TypeScript Engineering, Web Application Architecture, Technical Documentation

Nico Brandt is a JavaScript and TypeScript developer focused on building well-structured, maintainable, and scalable web applications.

He works extensively with modern JavaScript and TypeScript across frontend and backend environments, emphasizing type safety, code readability, and predictable application behavior.

...
JavaScript TypeScript Frontend Development Backend APIs Asynchronous Programming

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.