Git Tutorial: Fixing Common Mistakes and Undoing Bad Commits
HTML-код
- Опубликовано: 21 авг 2024
- In this video we will look at some common mistakes in Git and how we can fix these mistakes. Specifically we will cover how to discard changes since your last commit, amending commits, cherry-picking hashes, resetting to a specific commit, and reverting to a specific commit.
✅ Support My Channel Through Patreon:
/ coreyms
✅ Become a Channel Member:
/ @coreyms
✅ One-Time Contribution Through PayPal:
goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
www.amazon.com...
▶️ You Can Find Me On:
My Website - coreyms.com/
My Second Channel - / coreymschafer
Facebook - / coreymschafer
Twitter - / coreymschafer
Instagram - / coreymschafer
#Git
I made a slight mistake in the video. The -f option on git clean is for "force" and not for "files". The documentation can be found here for more info:
git-scm.com/docs/git-clean
You are a God send to humanity. Thank you :)
Explanation Very Clear.!! Please videos on Merge and Rebase. Thank you so much! I learn a lot from the videso.
thought it while watching, but got answer while came to make some comments on your video
Did you have to use -d or could you have taken it out
1:42 - Revert back the code that was written
3:36 - Updating the commit message alone (amend)
5:50 - Accidentally left off a file that we wanted to commit
7:38 - Move the commits to a different branch (cherry-pick)
10:26 - 3 different types of reset
13:38 - Getting rid of untracked files (git clean)
15:01 - Retrieve critical files that were lost, and you want them back (git reflog)
18:10 - Backing out changes, when other people have already checked out your changes (git revert)
Ajeeth Kumar Thanks for this Ajeeth👍👍
Thanks!
Thanks dude. You saved my time🙏🏻
thanks!
Thanks a lot. Your comments helped clearly understand what Corey was trying to say.
Am DevOps. Best tutorial for python and git so far. Even paid tutorials are not able to reach this level of profession . Keep it up :)
I am git newbie. This video saved my files that I thought I lost in a series of unintended commits. About 2 weeks worth of work! Thanks so much Corey and keep up the good work.
One of the best git (or any other) tech videos i've seen in a long long time! Great job!!
This.
Absolutely. No bullshit ego stuff up front or at end. Just right to the point with clear simple examples and explanations. Bravo
This is the second video I've watch by Corey. I've been in software development for over 20 years and he explains Git better than anybody I've come across. Keep up the great work you're doing. :)
I can see simplicity and at the same time your professional way of explaining it. Thank you for investing your time to save our's
After deciding to ditch the Git GUI in favor of command-line, I came across your videos. You have done a fantastic job compiling the essentials and demoing them! It feels like I finally understand what ACTUALLY is going on when I use these commands. Thank you!!
Brilliant structure and sequencing and crystal clear examples. A lot of key functionality covered effectively and concisely.
The most awesome tutorial about git reset/checkout/revert commands, I ever seen so far. Great! Thankyou!
Thanks!
Came here to say this.
Very very helpful tutorial for some of the more advance/obscure features related to rollback and reset. While this tutorial is long and someone in need of quick answer may run out of patience, I still recommend a good listen. Its better to know details rather than following commands without knowing basics. Thanks Corey for quality tutorial.
Wow. Watched all the videos on GIT. The flow and structure of the lecture(s) in all the videos is so smooth, that I Never had to rewind and ponder .." what did he say"... . More than perfect !
I paid 30€ for a git course of multiple hours. Well, I just discovered this video and it's quite better for 0€. Thank you
Perfect video, thanks! Keep it going, guys like you make this world a better place.
1 advice though: use head/head~/head~n/head^ syntax instead of sha-1 codes so that you can focus more on the intention and less on the implementation details of git.
For example:
10:40 - instead of using git log to find sha-1 codes, just use git reset --soft head~
(I want to reset to the second to latest commit)
20:00 - instead of using git log to find sha-1 codes, just use git diff head~ head
(i.e. I want a diff between second to latest commit and latest commit on the branch I'm on)
additional tips:
- checkout head^ which differs from head~ only when you have merge commits. (you can also use head^n)
- use head~n to go back n commits into the past.
- head is a synonym for the sha-1 of the latest commit.
After watching this video, I wish I could give it a thumbs-up 51 times so you hit 1000. Deserves it!
Despite the quick 'clears', which throw off and freak out beginners, this is the clearest explanation of fixing mistakes and changing history. Thanks.
Best git tutorial ever made on planet earth.
The BEST video on advanced git out there. I'm amazed by the use cases Corey has shown. I can't thank you enough for the efforts you put. I'll definitely do my part to support your channel.
Exactly what a developer needs rather than bombing with extra useless stuff on git. Good one.....Thanks...
This is the best video tutorial for Git. Neat, straight to the point, stunningly clear. High quality teaching.
I gotta be honest. I am new to all of this and I was a liitle bit intimidated by Git commands but damn... These videos are perfect. Thank you very very much!
I've never learned something about version control before but the way how you teach programming stuff is just amazing. While watching the first two videos about git I was myself asking questions like "ok but what if I accidently write a wrong comment" but you go through all those traps and show the appropriate solutions. Thanks for sharing your knowledge!
You are awesome. your teaching skills are extraordinary In 21 minutes you just cleared everything that I need to understand to get rid of all those confusions that often happened to me.
Thank you so much
This is one of the best videos for someone who manages git repository. Loved it
On 2:13 you didn't write a bunch of gibberish. You wrote exactly the same line 4 times except for the line number 4.
You exactly wrote sdfasdfasdf 4 times. Your talent
This is a must watch for every junior dev (including me).
this guy deserve a medal for this :)
One of the most helpful video on git that I came across, great job :)
Thank you so much for this tutorial. A lot of guides and videos focus on the 'happy' path of using git in development, but tend to leave aside the ugly bits that creep into our workflow more often than we'd expect.
very good tutorial
as a suggestion: if you use "git log --oneline --graph --all" is better than "git log" for new users.
you can also define new alias at first and use it instead of "git log":
how to create an alias command:
alias ThisOne="git log --oneline --graph --all" is better than "git log"
--
and now you can you "ThisOne" instead of "git log"
Best Regards
Presenter has good knowledge on the topic & great presentation skills.... That's what makes this video great !!! Thanks for sharing your knowledge....
Not commenting anything special, cause Only God knows how this tutorial helped me . Thanks a ton brother !
Thanks a ton for your efforts in making this. All your videos are amazingly well explained in simplistic way.
That's what 'advance' git tutorial i've been looking for... superb thank you
For reset --hard, you don't need to use checkout and then create a backup to restore. YOu can simply use reset --hard . Say A->B->C, after doing git reset --hard B, you can do git reset --hard C to go back to C. The only issue with --hard is that all uncommitted changes will be lost.
Complete undoing in just 21 minutes...
Great video...
Best git video I've ever seen by far. Well done!
Best git tutorial out there
One of the best git videos I have seen. Thank you Corey!
Best video on git ever!! intuitive and covers most of the practical use cases!
Cleared lot of doubts! Thanks!
Cory you are life sever !!! I was crying ...
I love the way you teach. It's very easy to understand and apply everything, I do recommend your lectures to everyone cause you are super cool. Thanks man
Lots of useful information in one place, I really enjoyed it :) Thanx Corey
improper use of git has cost a lot of people their jobs, do you know what a great video you have made....cheers man.Thank You.
Best git videos I have ever seen great job bro!!
Best of the best!!Thank you is an understatement!!
No more gitkraken for cherry-picking! 🕺🏿 Awesome video! Thanks for this.
You are amazing.. I have seen tons of videos.. But after watching this, i was like.. This is how you explain.. Thank you for taking out time to make this amazing video 😍
Just amazing Corey. Thanks!
reflog FTW!
Perfect Git Tutorial, BTW while studying the tutorial, trying "git reflog" i accidently typed reset commit id instead of checkout and then the backup branch hasle and guess what it gave me the same thing!
Thanks a lot really great tutorial
Great video. Clear and densely packed info, with excellent examples. Thank you.
You explain everything very clearly and in a good pace
I loved the lessons. getting more in depth knowledge on git.
Thanks Corey !!!. you are the best
Awesome tut. With examples it made damn easy to understand
Dude!!! Thank you so much for these git walkthroughs, best on youtube IMO!
You are an absolute legend and a True teacher ❤️🔥
thanks a lot . it was really helpful video which Cleared most of our doubts. and probably will save hassle in future.
Wow!!! This is perfect! Excellent explanation. Thank you
@Corey Schafer thank you for this tutorial. You're a life saver.
Thank you man u saved my project
love from india
Corey's videos are the best
Thank you Corey
Really good straight forward tutorials. Highly appreciated Corey.👍
one of the Excellent video on git..thank you so much
Great tutorial on git. I highly appreciate your efforts. Many thanks
Nicely covered all git mistakes that people generally do. Thank you very much for making this video.
Outstandingly useful, Thank you.
Really a great video. Learnt a lot from this video.
Thanks
I learned a lot from your second video on git. Thank you again.
Thank you for the high-quality tutorial. I have learned so much from you! Best wishes.
To get an overview over the complete git history type "git log --all --decorate --oneline --all". You can also assign an alias, so you don't have to write the previous command out everytime. alias graph="git log -all --decorate --oneline --all". Then you can just type graph
This is really some very very important content. Thank you. You just got one more subscriber :)
Such a well-explained video. Really helpful! Even for someone who has read most of the Pro Git book
Very Informative Video!
Thank You So Much. 🙌🏻
Wow, these videos are SUPER helpful. I'm going to watch it again.
Now I seriously understood what git reset does.
Crystal clear explanation 🔥
Amazing video. cleared all my doubts. Thanks a lot
Perfect Lesson
Great video straight to the point and not a second was wasted!!
I bet this video saved many lives.
"We want to get back to the way things were..."
Haha you said that so many times that I just started laughing after a while.
Great set of videos, by the way! Thanks for teaching me how to use git!
Lol wish we could do that for real in our lives
Awesome video. You explain things in a way that just make sense. Thank you.
great explanation, thanks for video!
One of the best , please keep on publishing great thanks , subscribed :)
This lesson is awesome! Thank you for very clear explanation!
Best explanation by far
Seriously, this is a life saver!
Amazing, user-friendly explanation!!!!
Awesome video. Thanks again.
Awesom tutorial i ever seen about git reset/reset /reset hard/revert commands
excellent video
What a wonderful explanation!!! Superb job. :)
Great Video. covers all the important scenarios
Great vid! When it comes to git reset there is also a "keep" option but I have never had a clear situation to see its benefits.
Very clear! Thank you 👍
Awesome explanation..!
Best git video I have seen .. keep it up
Fantastic video!
Just wow! Great tutorial on git undoing