Git Command Generator

Pick what you want to do and fill in your branch or file names. You get the exact commands to run, what they do, and a warning when a command rewrites history or deletes work.

Commands

    

Questions

What does "rewrites history" mean?

Some commands replace commits with new ones. That is fine on your own branch, but if others already pulled the old commits their history will no longer match yours. Then they must reset or rebase, so avoid it on shared branches like main.

Why --force-with-lease instead of --force?

--force-with-lease refuses to overwrite the remote branch if someone pushed to it since you last fetched. Plain --force would silently delete their work.

I lost commits after a reset. Can I get them back?

Usually, yes. Run git reflog to find the commit hash from before the reset, then git reset --hard <hash>. Uncommitted changes cannot be recovered this way.