0

Lately I find myself doing a lot of git rebase -i <commit_hash>^, replace the first 'pick' with an 'e', make the changes I want to the commit, and git rebase --continue.

I was wondering if I could make an alias to automate this process, but I fail to imagine how exactly. Is it possible to send the todo to a shell script, instead of the editor?

The intended result: running git edit <commit_hash> would do the process described above (except for the git rebase --continue), but without the need of me manually choosing the first commit.

phd
  • 82,685
  • 13
  • 120
  • 165
Luís Alves
  • 162
  • 8
  • https://stackoverflow.com/search?q=%5Bgit-rebase%5D+interactive+non-interactive – phd Oct 29 '20 at 17:48
  • https://stackoverflow.com/search?q=%5Bgit-rebase%5D+interactive+automatic – phd Oct 29 '20 at 17:48
  • 1
    This is it, here's the command I ended up aliasing for future reference: GIT_SEQUENCE_EDITOR="gsed -i '0,/pick/s//e/'" git rebase -i ${1}^ (gsed because I'm on mac) – Luís Alves Oct 30 '20 at 14:56

0 Answers0