Feature Request: `git commit --amend-to`
- From
- Aidan Gallagher <aidgal2@gmail.com>
- Date
- Sep 24, 2021, 16:04 UTC
- Message-ID
- <CAENgTz0st6RpnVusP67-SSh2eENSxQn1_qiEqUDiMKzg=r54vQ@mail.gmail.com>
- In-Reply-To
- <CAENgTz2DoStQEqoKYKa-qMcyaez64u55mnv1HHOzDm392fuEqQ@mail.gmail.com>
`git commit --amend` is very useful for adding changes to the previous commit quickly.
Unfortunately, it is more difficult to add changes to older commits. To do so I have to enter interactive rebase, mark the commit to change, make the changes, amend the previous commit, and continue the interactive rebase.
It would be nice if there was a single command to do this like `git commit --amend-to SHA`
I have solved this issue for myself with this handy alias I found online ``` git config --global alias.amend-to '!f() { SHA=`git rev-parse "$1"`; git commit --fixup "$SHA" && GIT_SEQUENCE_EDITOR=true git rebase --interactive --autosquash "$SHA^"; }; f' ```
I think it would be beneficial if a command `git commit --amend-to` could be officially added.
Thanks, Aidan Gallagher