DevOps & Version Control 100% Client-Side Privacy

Git Command Builder & Emergency Fixer

Quickly resolve common Git accidents, build complex Git commands with customized parameters, and browse an instant emergency cheat code reference.

Frequent Emergencies:

Undo last commit & keep all changes staged

Takes back the latest commit so you can re-commit or edit, keeping all files in the staging area.

Safe (Non-Destructive)

Completely safe. Your code modifications remain untouched and ready in the staging area.

Customize Parameters

Generated Terminal Command
git reset --soft HEAD~1

How This Command Works

  • git reset --soft HEAD~1→Moves HEAD pointer back by 1 commit(s). All file edits stay in the staging index (green in git status).

Git Emergency Cheat Code Matrix

Fast, copyable terminal snippets for daily Git operations, disaster recovery, and everyday workflows.

git reset --soft HEAD~1safe
Undo last commit, keep changes staged
git reset HEAD~1safe
Undo last commit, keep changes unstaged
git reset --hard HEAD~1destructive
Undo last commit and discard all changes
git restore .destructive
Discard all uncommitted changes in tracked files
git clean -fddestructive
Remove all untracked files and directories
git merge --abortsafe
Cancel merge in progress and restore branch state
git rebase --abortsafe
Cancel rebase in progress and restore branch state
git rm --cached <file>safe
Stop tracking file in Git without deleting local copy
git commit --amend -m "new message"safe
Change message of the most recent commit
git commit --amend --no-editsafe
Add staged changes into previous commit without changing message
git cherry-pick <hash>safe
Apply a commit from another branch onto current branch
git revert <hash>safe
Create a new commit that inverts the changes of an old commit
git checkout -b <branch>safe
Create a new branch and switch to it immediately
git branch -m <new-name>safe
Rename currently checked out local branch
git push origin --delete <branch>destructive
Delete a branch from the remote repository
git branch -d <branch>safe
Delete a merged local branch safely
git branch -D <branch>destructive
Force delete an unmerged local branch
git branch -asafe
List all local and remote branches
git pull --rebase origin maincaution
Fetch and replay local commits on top of origin/main
git stash push -m "note"safe
Stash current changes with a descriptive label
git stash push -u -m "note"safe
Stash changes including untracked files
git stash popsafe
Apply most recent stash and remove it from stash list
git stash applysafe
Apply most recent stash and keep it in stash list
git stash listsafe
View all saved stash entries
git stash cleardestructive
Permanently remove all stash entries
git reflogsafe
View complete history of HEAD movements to find lost commits
git checkout -b <new-branch> <hash>safe
Resurrect a lost commit from reflog into a fresh branch
git log --graph --oneline --decorate --allsafe
Visual ASCII graph of all branches and commits
git diff HEAD~1 HEADsafe
Inspect diff changes introduced by the last commit
git blame -L 1,50 <file>safe
Show commit author and timestamp for lines 1-50 in file
git push --force-with-lease origin <branch>caution
Safely force push without overwriting teammates' newer commits
git remote -vsafe
List all configured remote repository URLs
git fetch --prunesafe
Fetch remote updates and remove deleted remote branch refs

Why Developers Keep This Git Fixer Bookmarked

Built to rescue your repository when things go wrong, without panic and without losing code.

01

Safety-First Guidance

Every generated command carries an explicit safety badge (Safe, Caution, Destructive) so you know exactly what touches your disk and remote history.

02

Reflog & Disaster Recovery

Step-by-step commands to bring back "deleted" branches, discarded commits, and aborted rebases using Git reflog snapshots.

03

Safe Force Pushing

Encourages git push --force-with-lease instead of reckless force-pushing, preventing accidental overwrites of your teammates' work.

04

100% Client-Side & Private

All command building and filtering occurs completely in your web browser. No repository names, paths, or code ever leave your machine.

3-Step Golden Rule for Git Emergencies

What to do the moment you make a mistake in your Git repository.

1

1. Don't Panic & Check Working State

Run git status before typing any reset or clean command. Know whether your changes are uncommitted, staged, or already committed.

2

2. Consult git reflog Before Hard Resets

Git almost never loses committed data immediately. If you accidentally reset or delete a branch, git reflog holds the commit hash for days.

3

3. Use Non-Destructive Solutions First

Prefer git reset --soft over --hard, git restore over git checkout, and git stash over discarding changes so you always have a fallback.

Frequently Asked Questions About Git Emergencies

Technical insights to help you master Git history, undo mechanisms, and safety best practices.

What is the exact difference between git reset --soft, --mixed, and --hard?

git reset moves the HEAD branch pointer backward. --soft leaves all modified files in the staging area (ready to re-commit). --mixed (the default) leaves your file edits in the working directory but unstaged. --hard wipes out all file modifications and resets both the index and working directory to match the target commit, permanently discarding uncommitted work.

Can I recover a commit or branch that I deleted with git reset --hard?

Yes! As long as the work was committed at least once, Git keeps unreachable commit objects in its local repository for at least 30 days before garbage collection runs. Run `git reflog` to find the commit hash from before your reset, then run `git checkout -b recovered-branch <commit-hash>` to resurrect it.

Why should I use git push --force-with-lease instead of git push --force?

Standard `git push --force` blindly overwrites the remote branch even if someone else pushed new commits while you were working. `git push --force-with-lease` checks whether the remote ref matches your local tracking branch before overwriting. If a teammate has pushed newer commits, the push will be safely rejected instead of destroying their work.

I accidentally committed an API secret or password. How do I remove it?

First, immediately revoke and rotate the credential. If the commit is only local, run `git reset --soft HEAD~1` and remove the secret. If the commit was already pushed to a remote repo, you must purge it from git history using `git-filter-repo` (recommended by Git) or `git filter-branch`, and force-push the updated tree.

How does git stash work and how do I include new untracked files?

By default, `git stash` only stores modified tracked files. To also stash new files you just created (untracked files), add the `-u` (or `--include-untracked`) flag: `git stash push -u -m "my stash note"`. You can retrieve your work anytime with `git stash pop`.

How do I safely stop or cancel a messy merge or rebase conflict?

To cancel a merge in progress, run `git merge --abort`. To cancel an interactive or standard rebase in progress, run `git rebase --abort`. Both commands immediately exit the conflict resolution state and restore your working directory and branch pointer to exactly how they were before you started.

Explore Related Developer & DevOps Tools

Complement your workflow with free, private, browser-native utility suites.