1 00:00:07,480 --> 00:00:17,590 Welcome back to the second part of my little GitHub for Dummies series. 2 00:00:17,590 --> 00:00:24,080 One thing I forgot on the last video is how to sync if someone else has made a change. 3 00:00:24,080 --> 00:00:25,080 Okay. 4 00:00:25,080 --> 00:00:33,840 Let's consider this repository here, we have nothing inside; so this is actually the remote 5 00:00:33,840 --> 00:00:35,920 repository here on GitHub. 6 00:00:35,920 --> 00:00:52,360 So, we will again create a little README file, add "README: and then we say "git add" and 7 00:00:52,360 --> 00:01:08,670 then we say "git commit" "blahblah" and then "git push". 8 00:01:08,670 --> 00:01:16,660 Then we have the README file here, and now let's create a new file in the remote repository 9 00:01:16,660 --> 00:01:22,710 that's something which will happen also if someone else pushes something to that repository. 10 00:01:22,710 --> 00:01:33,270 You will see a new file... and this is now only in the remote repository and not in my 11 00:01:33,270 --> 00:01:34,270 Local (repository). 12 00:01:34,270 --> 00:01:38,850 You see here, there's only the README and not the new file. 13 00:01:38,850 --> 00:01:50,030 To obtain this new file, you say just "git pull" and then you see here the new file is 14 00:01:50,030 --> 00:01:51,680 also here. 15 00:01:51,680 --> 00:01:54,630 And yeah, that's basically it. 16 00:01:54,630 --> 00:02:02,610 And then interestingly let's say you are, for example, working on a huge sub-project 17 00:02:02,610 --> 00:02:09,950 in the repository and you don't want to interfere with the main work going on. 18 00:02:09,950 --> 00:02:18,980 The main work is basically called a branch, which is "master" You can create your own 19 00:02:18,980 --> 00:02:19,980 branch. 20 00:02:19,980 --> 00:02:26,720 So you can say, "Git branch mybranch" for example. 21 00:02:26,720 --> 00:02:37,700 So, then you say "git status" we still see that we are here on the master branch. 22 00:02:37,700 --> 00:02:48,620 Now we say "git checkout mybranch" and now, see, we are switched to my branch. and now 23 00:02:48,620 --> 00:02:54,690 we say "git status" and you also see here we are on mybranch. 24 00:02:54,690 --> 00:03:10,700 Now what I do is... here we have those two files, and we say "# stuff on branch" here 25 00:03:10,700 --> 00:03:22,570 and we say "stuffonbranch.txt" so "git add stuffonbranch.txt" then "git commit" and "bla" 26 00:03:22,570 --> 00:03:25,310 and "git push" 27 00:03:25,310 --> 00:03:35,260 Ah yeah, we have to also create this branch remotely. 28 00:03:35,260 --> 00:03:46,340 So, and now we push it to a remote branch. 29 00:03:46,340 --> 00:03:53,710 Now we can actually see that mybranch has been created here and you see here the file 30 00:03:53,710 --> 00:03:57,010 stuff on branch which is not on the master. 31 00:03:57,010 --> 00:04:03,230 So, what we do now here is we switch back to the main branch. 32 00:04:03,230 --> 00:04:16,340 So that's "git checkout master" and then we say "git merge mybranch" 33 00:04:16,340 --> 00:04:25,410 So this has been automatically merged so you see here we have stuff on branch also in my 34 00:04:25,410 --> 00:04:28,880 local folder here. 35 00:04:28,880 --> 00:04:36,340 But we see here it is still not in the master, ok? 36 00:04:36,340 --> 00:04:51,360 So we say "git push" and if you now refresh you see stuff on branch. 37 00:04:51,360 --> 00:04:58,450 So what happened here is we have merged from the local branch repository into the local 38 00:04:58,450 --> 00:05:05,570 master repository and now we push the contents of the local master repository to the remote 39 00:05:05,570 --> 00:05:12,270 master repository, and that way we have merged branch back into the master branch. 40 00:05:12,270 --> 00:05:16,900 So, that is all for now here. 41 00:05:16,900 --> 00:05:23,740 In the next video, I will show you how to actually create pull requests and contribute 42 00:05:23,740 --> 00:05:28,690 to foreign repositories.