Explore our collection of 150+ developer tools, PDF editors, and image converters. Everything runs locally in your browser.
Explore our collection of 150+ developer tools, PDF editors, and image converters. Everything runs locally in your browser.
Step-by-step interactive commands to rescue your Git repo when things go wrong.
Move your commit to a new branch without losing your work:
git branch new-feature-branch git reset HEAD~ --hard git checkout new-feature-branch
Creates a new branch pointing at your current commit, resets your current branch back one commit, and switches you to the new branch.
Undo the commit and keep your changes unstaged so you can .gitignore it:
git reset HEAD~1 echo ".env" >> .gitignore git add .gitignore git commit -m "fix: add gitignore and remove secrets"
Soft-resets the last commit, leaving files modified on disk. Add the sensitive file to .gitignore, stage the rest, and recommit cleanly.
Change the message of the most recent commit:
git commit --amend -m "Your new and corrected commit message"
Updates the previous commit message without creating a new commit.
Reset your local branch to match the remote origin completely:
git fetch origin git reset --hard origin/$(git branch --show-current)
Warning: This permanently discards all unstaged and unpushed local changes.
Undo the commit while keeping all modified files in your staging area:
git reset --soft HEAD~1
HEAD points to previous commit; your changes remain staged, ready to add more code and re-commit.
Delete local branch and tell the remote to delete its reference:
git branch -d branch-name git push origin --delete branch-name
Removes the local branch and removes the remote tracking branch on origin.
Use git reflog to recover any commit made in the last 30 days:
git reflog # Find your commit SHA (e.g. abc1234) git checkout -b recovered-branch abc1234
Git reflog tracks all HEAD movements. Commits are almost never deleted immediately.
Stash your uncommitted work and re-apply it later:
git stash push -m "wip-feature" git checkout other-branch # Later when you return: git stash pop
Saves dirty working directory state onto a temporary stack.