Skip to content

Comment on Git Is Simpler Than You Thinkparent

Comments

You're kindly assuming people never enter the wrong command by accident.

Undoing a commit, for example, is very common and necessary, especially for beginners.

The easiest way to undo a commit is to treat git just like you would Subversion or Mercurial: Use 'git revert $COMMIT_ID' to reverse the generated commit, or simply fix things by hand and commit again.

Sure, you can edit the broken commit, if you value a pretty commit history. But again, this requires understanding git well enough to predict the effects. What happens if you run 'git commit --amend -a' after pushing the original commit? What if another user already pulled? How will you fix the resulting mess?

If you can answer these questions, then you'll have no problems editing history. If you can't, then you may be signing up for a lot of pain.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.