Advanced

Advanced Git

Level up with stash, cherry-pick, bisect, and other powerful Git techniques.

Git Stash

Temporarily save uncommitted changes so you can switch branches or pull updates.

Cherry-pick

Apply a specific commit from one branch to another without merging the whole branch.

Git Bisect

Binary search through your commit history to find which commit introduced a bug.

.gitignore

Tell Git to ignore specific files (node_modules, .env, build files, etc.).

Example

bash
# Stash - save work temporarily
git stash          # stash uncommitted changes
git stash pop      # restore stashed changes
git stash list     # view all stashes
git stash apply stash@{1}  # apply specific stash

# Cherry-pick - apply specific commit
git log --oneline feature/other-branch
git cherry-pick abc1234  # apply that commit here

# Interactive rebase - clean up history
git rebase -i HEAD~5
# Commands: pick, squash(s), fixup(f), edit(e), drop(d), reword(r)

# Amend last commit
git commit --amend -m "Better commit message"
git commit --amend --no-edit  # add staged changes to last commit

# Reflog - view history of HEAD movements
git reflog         # see all your recent actions
git checkout HEAD@{5}  # go back to where HEAD was 5 moves ago

# Bisect - find bug with binary search
git bisect start
git bisect bad           # current commit is broken
git bisect good v1.0.0   # this version was fine
# Git checks out a middle commit - test it, then:
git bisect good          # or: git bisect bad
# Repeat until Git finds the bad commit
git bisect reset

# .gitignore file
cat .gitignore
# node_modules/
# .env
# dist/
# *.log
# .DS_Store

# Git aliases
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.lg "log --oneline --graph --all"
git lg  # now works as shortcut
Try it yourself — BASH