Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.


How to Undo Mistakes With Git Using the Command Line

via freeCodeCamp


This course teaches learners how to undo, revert, recover, and fix mistakes using Git through the command line. The learning outcomes include understanding how to discard changes, restore deleted files, fix commits, revert history, reset to old revisions, recover deleted commits and branches, and utilize interactive rebase for editing and squashing commits. The course employs a tutorial-based teaching method with practical examples and demonstrations. It is intended for individuals familiar with Git basics who want to enhance their version control skills and learn advanced techniques for managing and manipulating Git repositories effectively.


) Introduction.
) Hosted by Tower.
) Git as your safety net.
) Discard all local changes in a file.
) Please be careful: discarding local changes cannot be undone!.
) Restoring deleted files.
) Discard chunks / lines in a file.
) Discarding all local changes.
) Fixing the last commit.
) What "rewriting history" means.
) Reverting a commit in the middle.
) Resetting to an old revision.
) Resetting a file to an old revision.
) The Reflog.
) Recovering deleted commits.
) Recovering deleted branches.
) Moving a commit to a new branch.
) Moving a commit to a different branch.
) Interactive Rebase: an overview of what you can do.
) Interactive Rebase: how it works in general.
) Editing old commit messages with Interactive Rebase.
) Deleting commits with Interactive Rebase.
) Squashing multiple commits into one with Interactive Rebase.
) Adding changes to an old commit with Interactive Rebase.
) Splitting/editing an old commit with Interactive Rebase.
) Reminder: don't rewrite commits that you have already shared!.
) First Aid Kit for Git: a set of short videos and a cheat sheet, free to download (

Taught by


Start your review of How to Undo Mistakes With Git Using the Command Line

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.