Jesse Hallam
Jesse Hallam

Reputation: 6964

Rewriting git commit history

Assuming we have a git commit history which looks like:

ZZ [origin/master] A -> B -> C -> D -> E [master]

We want to:

The result should look like:

ZZ -> XX [master][origin/master]

Where XX is the commit encompassing the changes of prior commits A..E

Upvotes: 1

Views: 476

Answers (1)

pktangyue
pktangyue

Reputation: 8534

You can try:

git reset --hard E
git reset --soft ZZ
git commit 'comment'
git push orgin master

--soft

Does not touch the index file nor the working tree at all (but resets the head to , just likeall modes do). This leaves all your changed files "Changes to be committed", as git status would putit.

Upvotes: 3

Related Questions