What is the git commands to delete unwanted commits that haven't been pushed to the remote?
I don’t want to pollute the main tree with unwanted commits.
- github fork confusion
- why is it suggested to create a local branch tracking the remote branch in git when you call pull down the actual remote branch
- Show local commits when branch name contains slash
- Gitolite create repository with gitolite user locally
- Netbeans git can't checkout local branch - Conflicts during checkout
- Can I change the default directory on my local drive for all Git activity?
3 Solutions collect form web for “What is the git commands to delete unwanted commits that haven't been pushed to the remote?”
If you haven’t yet pushed them to the remote, it should be easy to delete them.
git branch -D <branch-to-delete>
will forcibly delete a branch that you don’t want to keep.
Try looking up rebase- there is a good series of videos here: http://www.ava.co.uk/git
Try this one. This way it’s possible to drop single commit. I assume the commit you want to drop is no further than 16 steps back from the HEAD.
git rebase -i HEAD~16...HEAD