Back to Stories
Git Without Tears: Fixing the Three Mistakes Everyone Makes
Web Development

Git Without Tears: Fixing the Three Mistakes Everyone Makes

Rachel Kim

Rachel Kim

17 followers

11 Oct 20263 min read

Share this story

What git is actually doing

Git keeps a snapshot every time you commit. It is not a complicated backup service, it is a photo album: each shot is frozen, you can flip back through them, and you can always return to one you liked. Almost every crisis comes from believing the tool is out to delete your work. It is not, and there is almost always a snapshot sitting one command away.

Mistake one: committing to the wrong branch

You finish a feature, run a commit, and realise you were sitting on the main branch instead of your own.

  1. Create a branch where you are, which carries the commit with you
  2. Switch to that branch and confirm your work arrived
  3. Reset the original branch back one step so the change does not sit there twice

The same fix works in reverse if you committed to a teammate's branch by accident.

Mistake two: undoing too much

You change your mind after a commit and reach for a reset that wipes history. The safer habit is to keep the work and simply reverse the effect, which leaves a new commit on top rather than erasing the old one. Reserve hard resets for changes you have never shared, because once something has been pushed, rewriting it costs your collaborators a bad afternoon.

Mistake three: fighting a merge conflict

Conflicts are git telling you the truth, two people edited the same lines and someone must decide. Open the file, look for the marked sections, and choose line by line rather than mashing accept on everything. Then stage the file and commit as usual.

  • Take your version for your code, theirs for theirs, and write something new where both changed the meaning
  • Ask the other person if the decision is not yours to make
  • Never leave conflict markers in a file you are about to run

The habit that prevents all three

Commit small and often, with messages that say why, not what. Tiny commits are trivial to revert, easy to review and impossible to panic about. Big commits are where people lose hours, because undoing one means deciding whether to throw away three days of good work along with the mistake.

If you commit in small pieces, keep your own branch, and push regularly, you will spend your time writing code instead of recovering from it. That is the entire secret of git, and everything else is lookup.

Common questions

What git is actually doing?

Git keeps a snapshot every time you commit. It is not a complicated backup service, it is a photo album: each shot is frozen, you can flip back through them, and you can always return to one you liked. Almost every crisis comes from believing the tool is out to delete your work.

Keep reading

More in Web Development

Git Without Tears: Fixing the Three Mistakes Everyone Makes | WebSQ