A commit change that is edited as part of a reinstall in magit

I use Emacs + in many ways an incredible magic mode for working with git. There is one aspect of my workflow, although I cannot match that, and hence this question.

Sometimes you have a commit that needs to be refactored into separate commits. I can interactively rebase my commits using magit and declare that I intend to change the said commit.

Now I need to go to the git gui, select "amend last commit", which shows me the staged changes, and disable the parts that I want to become a separate commit. Then I commit, throw exceptions, and commit again - voila, I have a new commit in my history.

I still haven't found a way to accomplish this with Emacs. Any hints?

+3


source to share


1 answer


After you start the rebase instead of going to the gui, do magit-reset -head to HEAD ~ 1, this will put you in a position to stop the changes and also step through and commit at will, before finally Continue resetting from the buffer state of the magnet.


Example workflow script:



  • commit changes to file A (commit 1)
  • commit changes to file B and file C (commit 2)
  • commit changes to file D (commit 3)
  • understand that you want the changes in file B and file C to be separate commits
  • run magit-log

  • start interactive reload ( E) on commit 2.
  • indicate that you want to edit ( E) commit 2 and complete ( C-c C-c)
  • go back to the magit status buffer.
  • run magit-reset-head

    ( x), specify HEAD~1

    on the command line.
  • you will see the changes for commit 2.
  • disable changes in file C.
  • make incremental changes to file B.
  • and commit the changes to file C.
  • continue and finish rebase with R C

You will now have four commits, each of which will change one file in the order A, B, C, D.

+4


source







All Articles