Develumpen

Edit a specific git commit

I was on a trip with my work laptop when I decided to start a new personal Rails engine. I didn't realize that Rails would take my current git config info to fill in the .gemspec file. By the time I updated the git config for the project, my work email was already there.

With a mix of Stack Overflow and Copilot, here's how I fixed it:

$ git rebase -i HEAD~n
# In the editor, change 'pick' to 'edit' for the commit you want to fix
$ git add <file>
$ git commit --amend
$ git rebase --continue

I wanted to edit the first commit of the history and running the first command showed an error about an invalid upstream. This is where Copilot helped, even though I later realized somebody else had commented about this topic on Slack Overflow as well.

To edit the first commit, run the following command:

$ git rebase -i --root

I had to push force, but I didn't mind for this project.
#git