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