Back to Home
Git
Advanced Git commands for power users
stashresetcherry-pickadvanced
Git Advanced
Advanced Git commands for complex workflows.
Stashing
# Stash changes
git stash
# Stash with message
git stash save "Work in progress"
# List stashes
git stash list
# Apply latest stash
git stash pop
# Apply specific stash
git stash apply stash@{2}
# Drop a stash
git stash drop stash@{0}
Resetting
# Unstage files
git reset HEAD file.txt
# Soft reset (keep changes staged)
git reset --soft HEAD~1
# Mixed reset (keep changes unstaged)
git reset HEAD~1
# Hard reset (discard changes)
git reset --hard HEAD~1
# Reset to specific commit
git reset --hard commit_hash
Cherry Picking
# Apply specific commit to current branch
git cherry-pick commit_hash
# Cherry pick without committing
git cherry-pick -n commit_hash
# Cherry pick range
git cherry-pick start_hash..end_hash
Other Useful Commands
# Amend last commit
git commit --amend
# Revert a commit (creates new commit)
git revert commit_hash
# Find commit that introduced bug
git bisect start
git bisect bad
git bisect good commit_hash
# Clean untracked files
git clean -fd