If you have committed junk but not pushed,
git reset --soft HEAD~1[/code]
HEAD~1 is a shorthand for the commit before head. Alternatively you can refer to the SHA-1 of the hash you want to reset to. --soft option will delete the commit but it will leave all your changed files "Changes to be committed", as git status would put it.
If you want to get rid of any changes to tracked files in the working tree since the commit before head use --hard instead.
Now if you already pushed and someone pulled which is usually my case, you can't use git reset. You can however do a git revert,git revert HEAD[/code]
This will create a new commit that reverses everything introduced by the accidental commit.
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.