Amending commit that is edited as part of a rebase in magit

I’m using Emacs + it’s in very many ways fabulous magit-mode to work with git. There is one aspect of my workflow though that I can’t map to this, and thus this question.

Sometimes you have a commit which should be reworked into separate commits. I can interactively rebase my commits with magit, and declare my intend to edit said commit.

  • html export different branch
  • Get the VC root in Emacs Lisp
  • How can I tell Emacs my git branch has changed?
  • Which functions are missing in existing Emacs modules for work with git?
  • magit-grep, how to include or exlude file extensions?
  • Magit : how to see pre-commit hooks before editing commit log?
  • Now I have to switch over to git gui, select “ammend last commit” which shows me the staged changes, and unstage those parts I want to become a separate commit. Then I commit, stage the exclusions, and commit again – voila, I have a new commit within my history.

    I have so far not found a way to accomplish this using Emacs. Any hints?

  • Git reverting old version as new commit across file name changes
  • Git blind spot between staging and remote
  • Permission denied (publickey) copy from remote machine to local
  • How to config socks5 proxy on Git
  • Git “shortcut” for filepath?
  • How do I tell git-svn about a remote branch created after I fetched the repo?
  • One Solution collect form web for “Amending commit that is edited as part of a rebase in magit”

    After your begin the rebase, instead of going to the gui, do a magit-reset-head to HEAD~1, this will put you in the position to unstage the changes, and stage and commit as desired before finally Continuing the rebase from the magit status buffer.


    Example scenario workflow:

    1. commit changes to file A (commit 1)
    2. commit changes to file B and file C (commit 2)
    3. commit changes to file D (commit 3)
    4. realize that you want the changes to file B and file C to be separate commits
    5. run magit-log
    6. begin an interactive rebase (E) at commit 2.
    7. specify you want to edit (e) commit 2 and finish (C-cC-c)
    8. return to magit status buffer.
    9. run magit-reset-head (x), specify HEAD~1 in prompt.
    10. you will see the changes for commit 2 staged.
    11. unstage the changes to file C.
    12. commit the staged changes for file B.
    13. stage and commit the changes to file C.
    14. continue and finish the rebase with RC

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

    Git Baby is a git and github fan, let's start git clone.