How to Undo Mistakes With Git Using the Command Line


Git offers lots of different ways to undo, revert, recover and fix your mistakes. In this course, we’ll look at the bad things that can happen to you – and how Git can save your neck.

?? This course was created by Tobias Günther from Tower. Tower creates a powerful Git desktop GUI for Mac and Windows. You can download it here: https://www.git-tower.com

Note: This course focuses on using Git with the command line. You do not need Tower or any other GUI software to follow along.

?? Course Contents ??
?? (00:00) Introduction
?? (00:54) Hosted by Tower
?? (01:29) Git as your safety net
?? (02:50) Discard all local changes in a file
?? (04:28) Please be careful: discarding local changes cannot be undone!
?? (05:03) Restoring deleted files
?? (06:10) Discard chunks / lines in a file
?? (10:22) Discarding all local changes
?? (11:42) Fixing the last commit
?? (14:53) What “rewriting history” means
?? (15:54) Reverting a commit in the middle
?? (18:48) Resetting to an old revision
?? (21:48) Resetting a file to an old revision
?? (23:59) The Reflog
?? (24:38) Recovering deleted commits
?? (27:46) Recovering deleted branches
?? (31:22) Moving a commit to a new branch
?? (33:55) Moving a commit to a different branch
?? (35:57) Interactive Rebase: an overview of what you can do
?? (37:54) Interactive Rebase: how it works in general
?? (38:36) Editing old commit messages with Interactive Rebase
?? (41:29) Deleting commits with Interactive Rebase
?? (43:20) Squashing multiple commits into one with Interactive Rebase
?? (46:00) Adding changes to an old commit with Interactive Rebase
?? (51:54) Splitting/editing an old commit with Interactive Rebase
?? (54:01) Reminder: don’t rewrite commits that you have already shared!
?? (54:38) First Aid Kit for Git: a set of short videos and a cheat sheet, free to download (www.bit.ly/git-first-aid-kit)

?? Special thanks to our Champion supporters! ??
? Loc Do
? Joseph C
? DeezMaster

Learn to code for free and get a developer job: https://www.freecodecamp.org

Read hundreds of articles on programming: https://freecodecamp.org/news

And subscribe for new videos on technology every day: https://youtube.com/subscription_center?add_user=freecodecamp

Discover more from WIREDGORILLA

Subscribe now to keep reading and get access to the full archive.

Continue reading