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

Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
Learn essential Git commands and techniques in this comprehensive tutorial video. Master undoing commits, renaming branches, and checking out previous commits. Explore practical examples of restoring files, amending commit messages, creating and managing branches, handling merge conflicts, and reverting or resetting code to specific commit points. Gain valuable skills to effectively navigate and control your Git workflow, enhancing your version control capabilities for more efficient software development.

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.