Clean Git history (atomic commits) is the "Industry Standard" we all aim for. But let's be honest: in the heat of a sprint, nobody has time for it.
To fix a typo in a commit from 3 hours ago, a developer usually has to perform "Git Surgery."
Itâs too much friction. So, I decided to fix it. I built a custom alias called amend-to.
I wanted to make the right way the easiest way. Here is the ROI of the tool I built:
| The "Vanilla" Git Struggle đŤ | The git-sutra Way đ§ |
|---|---|
1. Run git log to find the hash. |
1. git amend-to <hash> |
2. git commit --fixup <hash> (Creates mess). |
DONE. |
3. git rebase -i --autosquash <hash>~1. |
|
| 4. Wait for text editor to open. | |
| 5. Verify the todo list manually. | |
| 6. Save and Close editor. | |
| 7. Hope you didn't pick the wrong parent. |
It worked perfectly. I felt like a wizard. đ§ââď¸
Then, I made the rookie mistake. I ran git pull.
Boom. đĽ
Suddenly, my clean history of 51 commits exploded into 72 commits. My terminal screamed with errors on files I knew I had just written.
I looked at the logs, and I saw this nightmare:
text
Auto-merging gitinit.cmd
CONFLICT (add/add):Merge conflictin gitinit.cmd