# Editing commit duplicates all following commits in all future branches

**URL:** <https://forum.sublimetext.com/t/editing-commit-duplicates-all-following-commits-in-all-future-branches/42993>\
**Category:** Sublime Merge\
**Created:** [March 29, 2019, 12:27pm UTC](https://forum.sublimetext.com/t/editing-commit-duplicates-all-following-commits-in-all-future-branches/42993 "2019-03-29T12:27:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbb](https://forum.sublimetext.com/user_avatar/forum.sublimetext.com/pbb/32/66967_2.png) [@pbb](https://forum.sublimetext.com/u/pbb)\
**Post date:** [March 29, 2019, 12:27pm UTC](https://forum.sublimetext.com/t/editing-commit-duplicates-all-following-commits-in-all-future-branches/42993/1 "2019-03-29T12:27:03Z")

</div>

I am not sure if this is a bug, or if it is by design and it’s just my limited knowledge of Git that gets me confused…

Say I have a branch with multiple commits, and another branch that splits off halfway:

```
A - B - C - D - E - F
              \ G - H

```

Now if I edit commit “C” (Context menu \> Edit Commit \> Edit Commit Contents), then I end up with the following tree:

```
A - B - C' - D' - E' - F'
      \ C - D - G - H

```

(Where C’, D’, etc contain the edit I did.)

Is this by design, or is there a bug?

---

<div class="post-metadata">

**Author:** ![michaelblyons](https://forum.sublimetext.com/user_avatar/forum.sublimetext.com/michaelblyons/32/56949_2.png) [@michaelblyons](https://forum.sublimetext.com/u/michaelblyons)\
**Post date:** [March 29, 2019, 6:39pm UTC](https://forum.sublimetext.com/t/editing-commit-duplicates-all-following-commits-in-all-future-branches/42993/2 "2019-03-29T18:39:40Z")

</div>

This is a Git thing, not specific to Sublime Merge. You can, if you wish, subsequently rebase `G` onto `D'` to give you a `G' - H'` branch off of `D'`. The reason this doesn’t happen automatically is that if anyone _else_ is using `G` or `H`, you are cutting their knees out from under them.

Here’s the CLI instructions for doing what I described. (Sorry I don’t know how to do it in SM)

> <https://github.com/git/git/blob/master/Documentation/git-rebase.txt#L100-L158>

---

<div class="post-metadata">

**Author:** ![pbb](https://forum.sublimetext.com/user_avatar/forum.sublimetext.com/pbb/32/66967_2.png) [@pbb](https://forum.sublimetext.com/u/pbb)\
**Post date:** [April 1, 2019, 12:04pm UTC](https://forum.sublimetext.com/t/editing-commit-duplicates-all-following-commits-in-all-future-branches/42993/3 "2019-04-01T12:04:54Z")

</div>

Thanks, that makes sense!

I haven’t figured out how to do a rebase on any random commit in Sublime Merge yet (as per your "rebase `G` onto `D'`"), I’ve only been able to rebase onto the top of a branch (which would be `F'` in my example).

---

<div class="post-metadata">

**Author:** ![michaelblyons](https://forum.sublimetext.com/user_avatar/forum.sublimetext.com/michaelblyons/32/56949_2.png) [@michaelblyons](https://forum.sublimetext.com/u/michaelblyons)\
**Post date:** [April 1, 2019, 2:51pm UTC](https://forum.sublimetext.com/t/editing-commit-duplicates-all-following-commits-in-all-future-branches/42993/4 "2019-04-01T14:51:59Z")

</div>

To do arbitrary sequences of commits, you need the 3-term `rebase --onto`. From this tree:

```
A - B - C' - D' - E' - F'
      \ C - D - G - H

```

into this tree:

```
A - B - C' - D' - E' - F'
                \ G' - H'

```

You’re going to do

```auto
git rebase --onto "D'" D H

```

Or, if it is helpful:

```auto
git rebase --onto desired-branch-point first-commit^ last-commit

```

Note the `^`! It is critical. Also, if you use a _branch_ reference for the `last-commit`, it will move the branch with the rebase. If you use the SHA hash, the branch will stay pointing at its old place.
