简体   繁体   中英

What is the git commands to delete unwanted commits that haven't been pushed to the remote?

If I have a few local topic branches I have made commits on and haven't yet pushed them to the remote, how can I delete them?

I don't want to pollute the main tree with unwanted commits.

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.

尝试查找变基-这里有很多视频: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM