Git Tutorial: How to Undo Git Commits, Rename a Git Branch and Checkout a Previous Commit
HTML-код
- Опубликовано: 8 сен 2024
- Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGra...
Undoing git mistakes can be difficult if you don't know how. This video steps through examples of how you can undo all types of actions in git as well as explaining git branches and merges. Full outline and timestamps below!
🕓 Outline with timestamps:
(0:04) Recap Quick Start
(1:20) git restore [filename] (undo changes)
(2:18) git restore --staged [filename] (undo staged files)
(3:09) git log (show log with details)
(3:45) git log --oneline (shows simplified log)
(4:35) git commit -v --amend (change last commit's message)
(6:35) git branch [newBranchName] (creates new branch)
(7:50) git branch --list (lists all branches)
(8:05) git checkout [branchName] (switch to this branch)
(8:10) working with more than one branch
(12:25) git branch -m [oldBranchName] [newBranchName] (renames branch)
(14:10) git checkout -b [newBranchName] (creates new branch and switches to it)
(15:00) git branch -D [branchName] (deletes branch permanently)
(16:00) git merge [branchName] (merges named branch into branch you are on)
(17:10) Understanding and handling git merge conflicts
(22:30) git checkout [commitNumber] (go back to a specific commit number)
(27:00) git revert [commitNumber] (revert code to a specific commit number by creating new commit)
(29:30) git reset [commitNumber] (reset code to a specific commit number and unstage the code that came after that commit)
(31:45) git reset [commitNumber] --hard (reset code to a specific commit and permanently delete the code that came after the commit)
📺 More Beginner Dev Videos:
freeCodeCamp: • Learn JavaScript - Ful...
Traversy Media: • JavaScript Crash Cours...
The Net Ninja: • Modern JavaScript Tuto...
✅ Follow Me:
Twitter: / yesdavidgray
Reddit: / daveoneleven
Medium: / davegray_86804
#git #commit #tutorial
Very useful hints, thanks!
You're welcome! 💯
wow, this is amazing! thank you
You're welcome!
Thank you
the best git tutorial! Thanks
Thank you!
so you can do a modification on the main branch and then decide to commit it in a different branch. that's why the file was still there in your first example. Because maybe it can be done from the main branch first. I guess
Good one, thanks!
When using Git and Github within VS Code, it's a convenient feature but I find it confusing to use. For one thing, if you forget to put a message in your commit, a sort of blue line progress indicator comes up and never goes away. It seems to go into an endless loop that I can't get out of unless I restart VS Code. I've run into this issue a number of times as it's easy to forget this step. So, it would be a convenient feature if I could get it to work.
It attempts to open a text editor (notepad prob) for you to type the message.
Thank you very much indeed :)
You're welcome!
awesome ,thank u
You're welcome!
Is there any plan to make full git workflow tutorial?
That's a great idea!