I don’t know how, bug I’ve arrived to a tree like this:
X1--X2--(a lot commits)--X25--X26 (master)
\ \
\ D1--D2--merge (demo)
D1'--D2'---------------------/
Where D1=D1′ and D2=D2′ and the merge is empty. This tree has been pushed to the server, but I’m the only person is working on it.
Not a problem at all, but I’d like to simplify this tree to a more logical one. Something like this:
X1--X2--(a lot commits)--X25--X26 (master)
\
D1--D2--merge (demo)
It’s possible to remove D1′ and D2′ from my tree?
Each commit in
gitpoints backwards to its parents. Becausemergepoints to the commits you don’t want to have anymore, you need to get rid ofmerge, not justD1'andD2'.To do that, use
git checkout demo; git reset --hard D2. This will move yourdemopointer back toD2.Note that you will be doing a Very Bad Thing if you push this to the server and anyone has made a commit that depends on
merge,D1', orD2'. Their local history will still have the orphaned commits!