[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,{\i1}git reset{\i0} is the command that allows you to shape history in your repository. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Whether you're undoing some changes\Nor crafting your commits differently, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this is the command for you. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,(bossa music) Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Welcome to the episode of Git and GitHub Foundations on the {\i1}reset{\i0} command. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,This command has a lot of power,\Nand a lot of modes. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Yeah, there's going to be three modes\Nwe're going to be working with here. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,There's going to be {\i1}soft{\i0};\N{\i1}mixed{\i0}, or the default; and {\i1}hard{\i0}. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,(music) Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,these adjectives are pretty descriptive, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,starting with the one that's the default, {\i1}mixed{\i0}. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,It alters both the history and the working directory. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So mixed, both things. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,And soft is going to take one or multiple commits Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and put all of their changes back into the staging area Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,to allow you to continue to craft\Na new commit out of that. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Hard, on the other hand, is a destructive operation Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,that's meant to erase things that you no longer wish to keep. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So with all three of these in our stable, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,let's look at {\i1}mixed{\i0} first. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,{\i1}Mixed{\i0} is the recommendation that most often gets shown to new Git users Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,because it shows up in the {\i1}status{\i0} command. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,When you have changes in the staging area\Nand you say {\i1}git status{\i0}, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,we see a Git reset head. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,That allows us to take those changes\Nout of the staging area Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and put them back into the working directory Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,with the {\i1}mixed{\i0} option. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,{\i1}Soft{\i0} is the way that I take some changes Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,that might have gotten too granular in nature. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,One, two, three, four, five commits Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,that I then realize all belong\Nin one transaction, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and to bring them all together\Nby a {\i1}git reset --soft HEAD~5{\i0} Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,the most recent five commits. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So with that command of using {\i1}soft{\i0} Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you can take all five of those commits Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and kind of squash them down\Ninto the staging area as one commit. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Pretty useful for reshaping history, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but reshaping history goes to the far end of the spectrum Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,to throw away commits that just don't add value. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,You don't want to send them, transmit them, or share them with others. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,That's where {\i1}hard{\i0} comes into play. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,If you completely want to throw away some of your work, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,maybe you're trying out some change that just didn't work out, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you can use the {\i1}git reset --hard{\i0} to throw those commits away completely. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,People might ask, then why would you make a commit? Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,But Git provides you a really nice safety net Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,through the {\i1}reflog{\i0} command that we'll look at in a future episode Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,that motivates you to make checkpoints with commits, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and knowing that you have {\i1}hard{\i0} at your disposal, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you can clean that history up anytime you like. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,(music)