0

Sometimes I accidentally amend the previous commit with the changes I want to make to the one before that, i.e. HEAD~1. I usually go into rebase interactive mode with git rebase -i, split the commit into two commits, complete the rebase. Then rebase again to fixup the original commit

Is there a quicker way to do this? Can I just git commit --amend after I split the commit, adding my amend changes to the staging area before amending?

Connor Blakey
  • 846
  • 1
  • 7
  • 8
  • Interesting workflow. Question: how do you split the commit in the first place? I tried and succeeded, but it seemed pretty arduous to do. As for your question, I don't see a quicker way because I think what you're suggesting would require a second rebase (to squash two commits into one) in the middle of processing the first rebase, which you cannot do. – joanis Mar 14 '19 at 16:19

1 Answers1

-1

It sounds like you want to "cherry pick" a change in your commit history to save it in a new branch, and then modify your previous commit to remove it.

Like you mentioned, that's pretty tricky from the command line. But, there are a number of tools around that make this easier. For example Git Extensions has an easy way to modify your commit history using it's graphical user interface instead of the command line.

JakeMc
  • 413
  • 6
  • 13