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

YouTube

How to Undo Git Commits, Rename a Git Branch and Checkout a Previous Commit

Dave Gray via YouTube

Overview

Learn how to effectively manage and undo Git commits, rename branches, and navigate through previous commits in this tutorial. The course covers a range of commands such as restoring changes, creating and deleting branches, merging branches, handling conflicts, and resetting code to specific commit points. The teaching method includes step-by-step examples and explanations, making it suitable for beginners looking to enhance their Git skills.

Syllabus

Recap Quick Start
git restore [filename] undo changes
git restore --staged [filename] undo staged files
git log show log with details
git log --oneline shows simplified log
git commit -v --amend change last commit's message
git branch [newBranchName] creates new branch
git branch --list lists all branches
git checkout [branchName] switch to this branch
working with more than one branch
git branch -m [oldBranchName] [newBranchName] renames branch
git checkout -b [newBranchName] creates new branch and switches to it
git branch -D [branchName] deletes branch permanently
git merge [branchName] merges named branch into branch you are on
Understanding and handling git merge conflicts
git checkout [commitNumber] go back to a specific commit number
git revert [commitNumber] revert code to a specific commit number by creating new commit
git reset [commitNumber] reset code to a specific commit number and unstage the code that came after that commit
git reset [commitNumber] --hard reset code to a specific commit and permanently delete the code that came after the commit

Taught by

Dave Gray

Reviews

Start your review of How to Undo Git Commits, Rename a Git Branch and Checkout a Previous Commit

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.