Up and Running with Git Transcripts
Chapter: Tips and fixing mistakes
Lecture: Fixes: Reset. Reset all of it!
0:00 Recall I said that source control lets you fearlessly change your files and try new ideas
0:05 If you try too many crazy ideas you're gonna end up with something that breaks
0:10 your application. Oh no. What do you do?
0:13 Well you can actually just leverage source control to fix it.
0:16 Let's see how we do that.
0:18 We're over here in PyCharm on our rock paper scissors game and well there's some
0:22 colors and squiggles that might make you think something is wrong.
0:25 Well let's just try to run it.
0:27 Ah syntax error. What is invalid rock like?
0:30 That looks fine. Oh no what have I done?
0:34 What have I done? And if you look at the read me the read me
0:37 even says oh no why did I write this?
0:39 What have I done? Oh well so it goes so it goes so we can
0:45 fix this in either a very fine grained way or a just please make it better
0:50 way. I'll show you three different tools.
0:54 First of all we could click this one and say just put it back,
0:57 put them all back. So this one says you have the readme.md
1:00 file selected. So you can just reset Just that one.
1:04 But I could check both of these and just hit roll back and it all,
1:09 put that back. Okay just undo it to the previous way,
1:13 it was in source control locally.
1:15 Remember this is a roll it back on this branch on this cloned repository,
1:19 put it back to whatever that was,
1:22 you could see how it was as well.
1:25 I could do a diff and actually just looking and well that's the thing that changed
1:29 Right? So you can actually see the diff as well and decide.
1:33 Well here it is and here's what it's going to roll back to.
1:37 Similarly in source tree, we can come over here and see there are three pending
1:41 commits and I can go over here and say,
1:43 you know this. Read me,
1:45 what have I done? Good question.
1:46 What have I done? I can right click on this and I don't say roll
1:51 back. I say reset. You can reset it to a particular commit or just
1:55 straight reset. This goes, put it back to the last check in.
1:58 I'm gonna git reset there and boom.
2:02 That goes back to well what status was it before?
2:05 Let's open it up and it just was it's normal read me a story that we
2:09 had going on? The other thing is we have this new file that's unadded
2:13 maybe we want to get rid of that.
2:15 So here we can right click and just say remove it says warning.
2:19 This is going, I don't even think it goes to the trash.
2:22 It's just a delete and it's gone.
2:23 So maybe put it in the trash or recycle bin is safer but I'll just do
2:27 that. Now we have this one other change.
2:30 Remember our apps still doesn't run,
2:34 still doesn't run, we want to fix that.
2:37 So we saw how to fix it in PyCharm.
2:38 We saw how to fix it in source tree,
2:41 let's see how to fix it in visual studio code.
2:43 So here's the same project, we've got our game and again it has this little
2:47 error here. Well let's just say for whatever reason we don't know what the problem
2:52 is that we want to fix it here,
2:54 you can see it's modified so if we go over to source we can just click
2:57 that little reset. Their discard changes.
3:00 Are you sure? Yes, I'm pretty sure.
3:03 Alright let's try to run it.
3:05 Oh thank goodness. Our alligator and Spock are back.
3:09 Let's let's just play some straight spock and see how it goes.
3:12 Oh yes the logical choice was to go straight spock and win the game.
3:18 More importantly we've taken our code that was broken using reset rollback and those kinds of
3:25 ideas to just put it back.
3:27 Alright so with source control we can just as long as we've saved it at a
3:30 good point we can go explore it like crazy here we just made a bunch of
3:34 changes and we rolled it back a more durable way would be to create a branch
3:39 and go crazy on that branch and if something goes wrong you can just delete the
3:43 whole branch which would do it for multiple commits as well but you've got to have
3:46 a little foresight there if you just made a mistake and you're like oh no I
3:50 just broke it since I last committed it will reset or roll it back,
3:54 depending on the language that the tool uses.