gitpractice.dev

brewly — Ch.4 · Undo something already shared

Exercise 5 of 9

Before you start

Never rewrite what others have

A pushed commit may already be on your teammates’ computers. Do not remove it. Add a new commit that does the opposite instead: that is git revert.

Git opens the editor with a ready-made message. Keep it with "Save and close".

git show <commit> displays one commit and its changes, so you can be sure which one to undo.

git log --oneline
find the commit
git show <commit>
see what it changed
git revert <commit>
commit the opposite change
git push
share the fix
You can reopen this any time with “Lesson”.

Continue on a desktop

Typing git on a small screen is no fun. Open this page on a laptop or desktop to practise.

Back to the path