← Back to notes

Git Tips I Always Forget

GitDevelopmentTips

Git Tips I Always Forget

Undo Last Commit (keep changes)

git reset --soft HEAD~1

Amend Last Commit Message

git commit --amend -m "New message"

Clean Untracked Files

git clean -fd  # files and directories
git clean -fX  # only ignored files

Stash with Message

git stash save "WIP: feature X"
git stash list
git stash apply stash@{1}

Cherry Pick

git cherry-pick <commit-hash>

View File from Another Branch

git show branch:path/to/file

Keeping these here because I always have to Google them!