git undo all local commits code example
Example 1: undo local commit
$ git reset --soft HEAD~1
Example 2: git remove all local commits
git reset --hard origin/<branch_name>
Example 3: revert unpublished commits
git reset --hard <hash-or-ref>
$ git reset --soft HEAD~1
git reset --hard origin/<branch_name>
git reset --hard <hash-or-ref>