1 00:00:06,580 --> 00:00:07,840 - [Instructor] Whether you're a professional, 2 00:00:07,840 --> 00:00:09,370 or an amateur developer, 3 00:00:09,370 --> 00:00:10,610 you most definitely heard 4 00:00:10,610 --> 00:00:13,040 about the concept of version control. 5 00:00:13,040 --> 00:00:15,210 There are tons of tools in the market, 6 00:00:15,210 --> 00:00:17,980 both commercial and open source. 7 00:00:17,980 --> 00:00:19,810 And usually you will find things 8 00:00:19,810 --> 00:00:23,140 like the version control system or VCS, 9 00:00:23,140 --> 00:00:26,500 or SubVersion for example, 10 00:00:26,500 --> 00:00:29,410 a concurrent version system or CVS, 11 00:00:29,410 --> 00:00:31,170 Team Foundation servers. 12 00:00:31,170 --> 00:00:32,340 And there are tons and tons 13 00:00:32,340 --> 00:00:33,890 and tons of other ones out there. 14 00:00:33,890 --> 00:00:37,220 However, there's one that in particular 15 00:00:37,220 --> 00:00:39,690 is extremely popular nowadays, 16 00:00:39,690 --> 00:00:41,600 and that is Git, right? 17 00:00:41,600 --> 00:00:43,290 And you probably have heard of Git 18 00:00:43,290 --> 00:00:45,920 because of GitHub, right? 19 00:00:45,920 --> 00:00:47,330 Or GitLab. 20 00:00:47,330 --> 00:00:49,020 And GitHub is basically, you know, 21 00:00:49,020 --> 00:00:51,640 a product or an ecosystem 22 00:00:51,640 --> 00:00:53,970 that was actually acquired by Microsoft. 23 00:00:53,970 --> 00:00:57,803 And GitLab is actually the community base, you know, 24 00:00:59,170 --> 00:01:02,000 I would say open source, you know, repository. 25 00:01:02,000 --> 00:01:04,260 However, what I want to actually explain 26 00:01:04,260 --> 00:01:06,440 is the concept of Git, 27 00:01:06,440 --> 00:01:08,790 and how to actually interact 28 00:01:08,790 --> 00:01:11,280 with things like GitHub and GitLab, 29 00:01:11,280 --> 00:01:12,720 or private repositories, 30 00:01:12,720 --> 00:01:14,090 and so on, right? 31 00:01:14,090 --> 00:01:16,250 Now, Git is open source software. 32 00:01:16,250 --> 00:01:17,350 You can actually download it 33 00:01:17,350 --> 00:01:19,330 from the link that I'm highlighting on the screen. 34 00:01:19,330 --> 00:01:21,220 However, if you're a Linux user, 35 00:01:21,220 --> 00:01:23,940 you may already have Git out the box, 36 00:01:23,940 --> 00:01:25,720 you know, install in your system. 37 00:01:25,720 --> 00:01:27,150 Or you can actually install it 38 00:01:27,150 --> 00:01:31,300 in operating systems like Debian or Ubuntu 39 00:01:31,300 --> 00:01:34,530 with a simple apt-get install git, right? 40 00:01:34,530 --> 00:01:39,530 Or equivalent, depending on the distribution. 41 00:01:39,600 --> 00:01:41,490 But what I want to actually go over 42 00:01:41,490 --> 00:01:43,430 is a few basic commands 43 00:01:43,430 --> 00:01:46,150 that you actually have to know for the exam, right? 44 00:01:46,150 --> 00:01:47,080 For example, you know, 45 00:01:47,080 --> 00:01:51,020 to create an empty Git repository 46 00:01:51,020 --> 00:01:53,120 in a specific directory, 47 00:01:53,120 --> 00:01:56,710 you can actually just run git init, right? 48 00:01:56,710 --> 00:01:59,210 And that with no arguments will initialize 49 00:01:59,210 --> 00:02:01,880 the current directory as a Git repository. 50 00:02:01,880 --> 00:02:04,200 However, you can also do git init, 51 00:02:04,200 --> 00:02:06,880 and then specify the directory itself. 52 00:02:06,880 --> 00:02:09,040 You also have git clone, 53 00:02:09,040 --> 00:02:12,010 and that clones the repository 54 00:02:12,010 --> 00:02:16,080 located in a specific, you know, in a repo, 55 00:02:16,080 --> 00:02:17,690 whether it's GitHub or GitLab, 56 00:02:17,690 --> 00:02:20,890 or a private GitLab repository, and so on. 57 00:02:20,890 --> 00:02:23,820 You also have configuration parameters. 58 00:02:23,820 --> 00:02:25,200 And it's actually, you know, 59 00:02:25,200 --> 00:02:26,820 those are actually set up 60 00:02:26,820 --> 00:02:29,930 by the git config command, you know, 61 00:02:29,930 --> 00:02:31,070 that you can actually use 62 00:02:31,070 --> 00:02:34,100 for things like defining the author name, 63 00:02:34,100 --> 00:02:38,050 and setting global configuration flags, 64 00:02:38,050 --> 00:02:41,140 setting even your GPG or PGP key 65 00:02:41,140 --> 00:02:44,070 to sign your commits, and so on. 66 00:02:44,070 --> 00:02:46,876 You also have the git add command, 67 00:02:46,876 --> 00:02:50,250 that stages all the changes in the directory 68 00:02:50,250 --> 00:02:54,290 that you actually initiated for the next commit. 69 00:02:54,290 --> 00:02:57,990 And then, you also have the git commit command, 70 00:02:57,990 --> 00:03:01,380 that basically commit the stage snapshot, 71 00:03:01,380 --> 00:03:04,730 but instead of actually launching a text editor, 72 00:03:04,730 --> 00:03:09,230 you can actually use the -m for the message, 73 00:03:09,230 --> 00:03:10,110 and that will actually, you know, 74 00:03:10,110 --> 00:03:11,550 each commit will actually have to have 75 00:03:11,550 --> 00:03:13,580 at least some description 76 00:03:13,580 --> 00:03:15,300 of what the commit is all about. 77 00:03:15,300 --> 00:03:18,150 And that's actually the message in this example. 78 00:03:18,150 --> 00:03:19,700 Now you also have the git status, 79 00:03:19,700 --> 00:03:22,510 which actually list which files are stage, 80 00:03:22,510 --> 00:03:24,297 unstage, or untracked. 81 00:03:24,297 --> 00:03:27,100 You have logging capabilities. 82 00:03:27,100 --> 00:03:29,570 And to display the entire commit history, 83 00:03:29,570 --> 00:03:31,780 you can actually use the git log. 84 00:03:31,780 --> 00:03:34,000 You can also use the git diff 85 00:03:34,000 --> 00:03:36,290 to show the unstage changes 86 00:03:36,290 --> 00:03:39,120 between your index and your working directory. 87 00:03:39,120 --> 00:03:42,210 Now there's a concept of branches, of course, 88 00:03:42,210 --> 00:03:44,830 in many development, you know, activities. 89 00:03:44,830 --> 00:03:47,810 And to list all the branches in your repository, 90 00:03:47,810 --> 00:03:50,210 you can actually use the git branch command. 91 00:03:50,210 --> 00:03:51,453 And to check out, 92 00:03:52,544 --> 00:03:54,260 or create a new branch, 93 00:03:54,260 --> 00:03:56,470 you can actually use the git checkout 94 00:03:56,470 --> 00:03:58,300 followed by the branch name. 95 00:03:58,300 --> 00:04:00,670 There's also the concept of merging 96 00:04:00,670 --> 00:04:02,080 and pull request, right? 97 00:04:02,080 --> 00:04:03,900 So if you actually want 98 00:04:03,900 --> 00:04:08,900 to push a new change to a repository, 99 00:04:10,040 --> 00:04:11,880 you can actually do a git push, you know, 100 00:04:11,880 --> 00:04:13,942 to push that branch, or you know, 101 00:04:13,942 --> 00:04:15,970 that change to a remote branch, 102 00:04:15,970 --> 00:04:19,700 whether it's the master branch or a specific one. 103 00:04:19,700 --> 00:04:24,160 Or you can actually do a pull request, 104 00:04:24,160 --> 00:04:26,010 and basically what it does 105 00:04:26,010 --> 00:04:27,870 is fetch the specify remote copy 106 00:04:27,870 --> 00:04:28,930 of the current branch, 107 00:04:28,930 --> 00:04:31,480 and immediately merges to a local copy. 108 00:04:31,480 --> 00:04:33,120 And then it actually, you know, 109 00:04:33,120 --> 00:04:34,560 provides the ability 110 00:04:34,560 --> 00:04:37,210 for you to then pull request. 111 00:04:37,210 --> 00:04:38,740 And a pull request, 112 00:04:38,740 --> 00:04:42,240 then it's approved by whoever the administrator, 113 00:04:42,240 --> 00:04:45,670 or the specific user of, you know, 114 00:04:45,670 --> 00:04:47,920 the author of that GitHub repository. 115 00:04:47,920 --> 00:04:51,923 Now, if I actually want to obtain information, 116 00:04:52,820 --> 00:04:55,060 things actually changes in that repository, 117 00:04:55,060 --> 00:04:56,270 and keep up to date, 118 00:04:56,270 --> 00:04:58,430 I can do a git fetch, right? 119 00:04:58,430 --> 00:05:00,810 To fetch a specific branch, 120 00:05:00,810 --> 00:05:02,250 or, you know, pretty much everything 121 00:05:02,250 --> 00:05:05,670 if you actually want to fetch all the remote references. 122 00:05:05,670 --> 00:05:09,240 And then you can do a git pull 123 00:05:09,240 --> 00:05:11,210 to fetch the specified remote copy 124 00:05:11,210 --> 00:05:12,540 of the current branch, 125 00:05:12,540 --> 00:05:13,610 and immediately merge it 126 00:05:13,610 --> 00:05:14,890 to your local copy as well 127 00:05:14,890 --> 00:05:17,700 to keep track of those changes, right? 128 00:05:17,700 --> 00:05:19,510 So of course, as you actually make changes, 129 00:05:19,510 --> 00:05:21,220 you can actually use the commands 130 00:05:21,220 --> 00:05:22,340 that I mentioned to you before, 131 00:05:22,340 --> 00:05:25,260 like git add, and git push 132 00:05:25,260 --> 00:05:28,920 to push any changes to a specific branch, 133 00:05:28,920 --> 00:05:32,160 or to the master branch in that case. 134 00:05:32,160 --> 00:05:33,740 Now the cool thing is that, 135 00:05:33,740 --> 00:05:37,070 DevNet has several labs 136 00:05:37,070 --> 00:05:39,580 that you can actually complete in your own. 137 00:05:39,580 --> 00:05:41,910 And in there, they not only provide 138 00:05:41,910 --> 00:05:43,510 an introduction to Git, 139 00:05:43,510 --> 00:05:47,320 but also, there's several repositories. 140 00:05:47,320 --> 00:05:48,610 Like for example, 141 00:05:48,610 --> 00:05:51,150 they have DevNet Express for DNA, 142 00:05:51,150 --> 00:05:54,410 cloud collaboration, data center infrastructure, 143 00:05:54,410 --> 00:05:55,890 that actually you can clone, 144 00:05:55,890 --> 00:05:59,040 and then use for your reference, 145 00:05:59,040 --> 00:05:59,873 and also, you know, 146 00:05:59,873 --> 00:06:02,590 to practice your skills as well, right? 147 00:06:02,590 --> 00:06:04,340 So definitely take advantage 148 00:06:04,340 --> 00:06:06,620 of all these labs and tutorials 149 00:06:06,620 --> 00:06:07,990 that are available for free 150 00:06:07,990 --> 00:06:09,603 from Cisco at DevNet.