About git command generator
Git has many commands and options, and a wrong one can lose work. Pick what you want to do, such as undoing a commit or stashing changes, and the tool gives the right command with a warning if it is risky.
Safe habits
- Run git status first to see what is going on.
- Prefer git revert on shared branches, because it adds a new commit rather than rewriting history.
- Avoid force pushes to shared branches. Use --force-with-lease if you must.
A worked example
You committed to the wrong branch. Choose 'move last commit to a new branch'. The tool suggests creating the branch with git branch fix/login, then git reset --hard HEAD~1 on the current branch, and switching with git switch fix/login. Read each step before running it, since reset --hard discards uncommitted work.
Safer habits
- Make a backup branch (git branch backup) before an operation you are unsure about.
- Use git status and git log --oneline often.
- git reflog can recover commits that seem to be lost.
