1

Assuming we have a git commit history which looks like:

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

We want to:

  • Rewind the history back to before A.
  • Keep the working directory of E.
  • Bundle all the changesets of A..E in to a single commit.
  • Push the outcome to remote.

The result should look like:

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

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

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Quick, simple, elegant. Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.