How to remove all commits of a topic Git branch?
问题 Suppose I have the following history: A---B---C----------D------------E master \ /\ / W1--X1--Y1 W2--X2--Y2 topic1 topic2 Is it possible to remove all topic branches and their commits as following A-B-C-D-E master 回答1: You have a few options for doing this. Solution 1: Squash Merges One solution is to simply use a hard reset with a few squash merges: git checkout master git reset --hard C git merge --squash topic1 git commit -m "Rewrite D" git merge --squash topic2 git commit -m "Rewrite E" #