[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.21,0:00:04.62,Default,,0000,0000,0000,,{\i1}Git reset{\i0} is the command that allows you\Nto shape history in your repository. Dialogue: 0,0:00:04.62,0:00:07.94,Default,,0000,0000,0000,,Whether you're undoing some changes\Nor crafting your commits differently, Dialogue: 0,0:00:07.94,0:00:09.40,Default,,0000,0000,0000,,this is the command for you. Dialogue: 0,0:00:09.65,0:00:11.24,Default,,0000,0000,0000,,♪ (bossa music) ♪ Dialogue: 0,0:00:14.75,0:00:18.15,Default,,0000,0000,0000,,Welcome to the episode of Git and GitHub Foundations on the {\i1}reset{\i0} command. Dialogue: 0,0:00:18.54,0:00:21.56,Default,,0000,0000,0000,,This command has a lot of power,\Nand a lot of modes. Dialogue: 0,0:00:21.56,0:00:24.51,Default,,0000,0000,0000,,Yeah, there's going to be three modes\Nwe're going to be working with here. Dialogue: 0,0:00:24.51,0:00:28.24,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,0:00:28.56,0:00:30.59,Default,,0000,0000,0000,,♪ (music) ♪ Dialogue: 0,0:00:31.03,0:00:32.92,Default,,0000,0000,0000,,these adjectives are pretty descriptive, Dialogue: 0,0:00:33.09,0:00:35.51,Default,,0000,0000,0000,,starting with the one\Nthat's the default, {\i1}mixed{\i0}. Dialogue: 0,0:00:35.83,0:00:39.65,Default,,0000,0000,0000,,It alters both the history\Nand the working directory. Dialogue: 0,0:00:39.100,0:00:41.71,Default,,0000,0000,0000,,So mixed, both things. Dialogue: 0,0:00:41.90,0:00:44.43,Default,,0000,0000,0000,,And {\i1}soft{\i0} is going to take\None or multiple commits Dialogue: 0,0:00:44.43,0:00:47.18,Default,,0000,0000,0000,,and put all of their changes\Nback into the staging area Dialogue: 0,0:00:47.18,0:00:50.05,Default,,0000,0000,0000,,to allow you to continue to craft\Na new commit out of that. Dialogue: 0,0:00:50.43,0:00:53.28,Default,,0000,0000,0000,,{\i1}Hard{\i0}, on the other hand,\Nis a destructive operation Dialogue: 0,0:00:53.28,0:00:55.89,Default,,0000,0000,0000,,that's meant to erase things\Nthat you no longer wish to keep. Dialogue: 0,0:00:56.21,0:00:59.55,Default,,0000,0000,0000,,So with all three of these in our stable, Dialogue: 0,0:00:59.55,0:01:01.43,Default,,0000,0000,0000,,let's look at {\i1}mixed{\i0} first. Dialogue: 0,0:01:03.48,0:01:05.17,Default,,0000,0000,0000,,{\i1}Mixed{\i0} is the recommendation Dialogue: 0,0:01:05.17,0:01:07.24,Default,,0000,0000,0000,,that gets most often shown\Nto new Git users Dialogue: 0,0:01:07.27,0:01:09.44,Default,,0000,0000,0000,,because it shows up\Nin the {\i1}status{\i0} command. Dialogue: 0,0:01:09.61,0:01:12.39,Default,,0000,0000,0000,,When you have changes in the staging area\Nand you say {\i1}git status{\i0}, Dialogue: 0,0:01:12.62,0:01:14.49,Default,,0000,0000,0000,,we see a Git reset head. Dialogue: 0,0:01:14.49,0:01:17.05,Default,,0000,0000,0000,,That allows us to take those changes\Nout of the staging area Dialogue: 0,0:01:17.05,0:01:18.88,Default,,0000,0000,0000,,and put them back\Ninto the working directory Dialogue: 0,0:01:18.88,0:01:20.37,Default,,0000,0000,0000,,with the {\i1}mixed{\i0} option. Dialogue: 0,0:01:20.67,0:01:23.38,Default,,0000,0000,0000,,{\i1}Soft{\i0} is the way\Nthat I take some changes Dialogue: 0,0:01:23.38,0:01:25.71,Default,,0000,0000,0000,,that might have gotten\Ntoo granular in nature. Dialogue: 0,0:01:26.03,0:01:27.87,Default,,0000,0000,0000,,One, two, three, four, five commits Dialogue: 0,0:01:27.87,0:01:30.85,Default,,0000,0000,0000,,that I then realize all belong\Nin one transaction, Dialogue: 0,0:01:30.85,0:01:36.91,Default,,0000,0000,0000,,and to bring them all together\Nby a {\i1}git reset --soft HEAD~5{\i0} Dialogue: 0,0:01:36.91,0:01:38.61,Default,,0000,0000,0000,,the most recent five commits. Dialogue: 0,0:01:38.84,0:01:41.10,Default,,0000,0000,0000,,So with that command of using {\i1}soft{\i0} Dialogue: 0,0:01:41.10,0:01:42.70,Default,,0000,0000,0000,,you can take\Nall five of those commits Dialogue: 0,0:01:42.70,0:01:46.28,Default,,0000,0000,0000,,and kind of squash them down\Ninto the staging area as one commit. Dialogue: 0,0:01:46.66,0:01:48.76,Default,,0000,0000,0000,,Pretty useful for reshaping history, Dialogue: 0,0:01:48.76,0:01:51.30,Default,,0000,0000,0000,,but reshaping history goes\Nto the far end of the spectrum Dialogue: 0,0:01:51.30,0:01:54.63,Default,,0000,0000,0000,,to throw away commits\Nthat just don't add value. Dialogue: 0,0:01:54.88,0:01:57.75,Default,,0000,0000,0000,,You don't want to send them,\Ntransmit them, or share them with others. Dialogue: 0,0:01:57.92,0:01:59.52,Default,,0000,0000,0000,,That's where {\i1}hard{\i0} comes into play. Dialogue: 0,0:01:59.52,0:02:01.85,Default,,0000,0000,0000,,If you completely want to throw away\Nsome of your work, Dialogue: 0,0:02:01.85,0:02:04.71,Default,,0000,0000,0000,,maybe you're trying out some change\Nthat just didn't work out, Dialogue: 0,0:02:04.71,0:02:08.06,Default,,0000,0000,0000,,you can use the {\i1}git reset --hard{\i0}\Nto throw those commits away completely. Dialogue: 0,0:02:08.61,0:02:11.27,Default,,0000,0000,0000,,People might ask, then why\Nwould you make a commit? Dialogue: 0,0:02:11.27,0:02:13.97,Default,,0000,0000,0000,,But Git provides you\Na really nice safety net Dialogue: 0,0:02:13.97,0:02:17.08,Default,,0000,0000,0000,,through the {\i1}reflog{\i0} command\Nthat we'll look at in a future episode Dialogue: 0,0:02:17.08,0:02:20.49,Default,,0000,0000,0000,,that motivates you to make\Ncheckpoints with commits, Dialogue: 0,0:02:20.49,0:02:22.65,Default,,0000,0000,0000,,and knowing that you have\N{\i1}hard{\i0} at your disposal, Dialogue: 0,0:02:22.65,0:02:25.18,Default,,0000,0000,0000,,you can clean that history up\Nanytime you like. Dialogue: 0,0:02:25.85,0:02:27.46,Default,,0000,0000,0000,,♪ (music) ♪ Dialogue: 0,0:02:27.76,0:02:32.18,Default,,0000,0000,0000,,There is one other cousin command\Nthat is often talked about with {\i1}reset{\i0} Dialogue: 0,0:02:32.18,0:02:34.15,Default,,0000,0000,0000,,and that's the {\i1}checkout{\i0} command. Dialogue: 0,0:02:34.15,0:02:37.70,Default,,0000,0000,0000,,The {\i1}checkout{\i0} command\Nis of a different granularity than {\i1}reset{\i0}, Dialogue: 0,0:02:37.70,0:02:41.27,Default,,0000,0000,0000,,which typically operates\Non the entire history of a repository. Dialogue: 0,0:02:41.70,0:02:45.40,Default,,0000,0000,0000,,{\i1}Checkout{\i0} is focused more\Non a directory or a file level precision. Dialogue: 0,0:02:45.76,0:02:49.29,Default,,0000,0000,0000,,Instead of undoing or changing\Nan entire commit, Dialogue: 0,0:02:49.29,0:02:52.71,Default,,0000,0000,0000,,we can go back in history\Nto a specific file at a commit Dialogue: 0,0:02:52.71,0:02:57.30,Default,,0000,0000,0000,,and pull that file and its version\Nback to our current working directory. Dialogue: 0,0:02:57.68,0:03:01.23,Default,,0000,0000,0000,,Clear communication is the goal\Nof all Git repository history. Dialogue: 0,0:03:01.49,0:03:06.02,Default,,0000,0000,0000,,So whether it's {\i1}git reset --hard,\Nreset --soft, reset --mixed{\i0}, Dialogue: 0,0:03:06.02,0:03:08.14,Default,,0000,0000,0000,,or the more precise {\i1}checkout{\i0} command, Dialogue: 0,0:03:08.14,0:03:12.84,Default,,0000,0000,0000,,use these to provide clear intent\Nabout your changes to your colleagues. Dialogue: 0,0:03:13.28,0:03:15.98,Default,,0000,0000,0000,,{\i1}Git reset{\i0} is a tool that can be\Na little bit intimidating Dialogue: 0,0:03:15.98,0:03:17.24,Default,,0000,0000,0000,,to new users of Git. Dialogue: 0,0:03:17.43,0:03:20.18,Default,,0000,0000,0000,,But it can be a powerful tool\Nto have at your disposal Dialogue: 0,0:03:20.18,0:03:22.47,Default,,0000,0000,0000,,for crafting beautiful repository history. Dialogue: 0,0:03:24.18,0:03:28.03,Default,,0000,0000,0000,,Thanks for watching another episode\Nof Git and GitHub Foundations on {\i1}reset{\i0}. Dialogue: 0,0:03:28.03,0:03:31.69,Default,,0000,0000,0000,,As always, don't forget to subscribe\Nto any of our channels on the side her. Dialogue: 0,0:03:31.69,0:03:33.81,Default,,0000,0000,0000,,Questions or comments?\NPut those down below Dialogue: 0,0:03:33.81,0:03:36.40,Default,,0000,0000,0000,,or check out one\Nof our other educational topics Dialogue: 0,0:03:36.40,0:03:38.52,Default,,0000,0000,0000,,on Git and GitHub\Nhere at the bottom. Dialogue: 0,0:03:38.79,0:03:40.66,Default,,0000,0000,0000,,♪ (music) ♪