Hacker News new | ask | show | jobs
by karolist 2091 days ago
Here's how I did it, but I think there should be a more optimal solution.

Inspect history, see that mistake was made 1 commit ago

  git log
Interactive rebase to edit last 2 commits

  git rebase -i HEAD~2
This will open rebase editor, change first line to below

  edit e794bf2 Add Hello world
  pick 77c37d2 Further work on Hello world
Fix typo in file.txt

stage modified file.txt and amend to commit

  git add file.txt
  git commit --amend

In the editor fix commit message (again?)

This causes merge conflict in file.txt, should be avoidable?

  git rebase --continue
Edit file.txt to remove conflict markers, make it as below

  Hello world
  Hello world is an excellent program.
Again, stage file.txt and continue, just exit the editor, no changes needed on the last commit.

  git add file.txt
  git rebase --continue
You can inspect with git log, but that's it

  git verify