Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • 11
    If he wants HEAD to look like A then he probably want the index to match so git reset --soft D is probably more appropriate.
    – CB Bailey
    Commented Sep 23, 2009 at 5:38
  • 2
    --soft resetting doesn't move the index, so when he commits, it would look like the commit came directly from a instead of from D. That would make the branch split. --mixed leaves the changes, but moves the index pointer, so D will become the parent commit. Commented Sep 25, 2009 at 14:42
  • 5
    Yes, I think git reset --keep is exactly what I have above. It came out in version 1.7.1, released in April of 2010, so the answer wasn't around at that time. Commented Nov 11, 2010 at 1:56
  • 1
    git checkout A then git commit above did not work for me, but this answer did.
    – SimplGy
    Commented Aug 29, 2013 at 3:38
  • 3
    Why is git reset --mixed D required? Specifically why reset? Is it because, without resetting to D, that, HEAD would point at A, causing B, C, and D to be "dangling" and garbage-collected -- which is not what he wants? But then why --mixed? You already answered "--soft resetting doesn't move the index..." So by moving the index, this means index will contain D's changes, while Working Directory will contain A's changes -- this way a git status or git diff (which compares Index [D] to Working Directory [A]) will show the substance; that user is going from D back to A? Commented Jan 10, 2016 at 18:03