Placeholder Image

字幕表 動画を再生する

  • COLTON OGDEN: All right.

  • Hello, Twitch.

  • My name is Colton Ogden and I'm joined today by Kareem Zidane.

  • Kareem, want to introduce yourself?

  • KAREEM ZIDANE: Yeah, hi, everyone.

  • My name is Kareem ZIdane.

  • I am a preceptor here at Harvard.

  • I work here with CS50, mostly doing software development stuff,

  • DevOps stuff, system administration.

  • COLTON OGDEN: Nice.

  • And some folks refer to you as Kareem the dream, is this correct?

  • Shout out to Spencer [INAUDIBLE].

  • KAREEM ZIDANE: [INAUDIBLE] yes.

  • COLTON OGDEN: Today we're doing the Kareem the dream stream.

  • KAREEM ZIDANE: OK, I did not see that coming.

  • COLTON OGDEN: And what are we talking about today on the stream?

  • KAREEM ZIDANE: We are going to be exploring a little bit

  • of the basics of git and GitHub.

  • COLTON OGDEN: OK, nice, nice.

  • For folks unfamiliar, what is git and GitHub sort of in a sentence or two?

  • KAREEM ZIDANE: So git is a distributed version control system, also known

  • as source control system, and git is usually

  • used to track changes in files and directory structures of our project.

  • And you can imagine this is quite handy for us developers

  • because we tend to do a lot of changes.

  • We always add features, fix bugs, refactor, improve stuff, and so on.

  • So you can imagine this gets quite handy to keep track of these changes,

  • be able to revert back to some of them, be able to build on top of them.

  • Git also stores these changes really efficiently.

  • It only stores the things that are necessary in this case,

  • so we don't have to worry about duplicating the whole codebase that we

  • have or duplicating all the files in our product.

  • It only stores the files that changed.

  • Another cool feature of git is that it also

  • allows us to work on different parts of the project, at once if you want to

  • or different features at once.

  • And this is also quite handy because, you can imagine,

  • we try to experiment with something or fix a bug or try to add a feature,

  • and we're not really sure that that's going to work out well or not.

  • So git really makes it easy as well to do this kind of thing.

  • And lastly, git also allows us to collaborate with other people

  • pretty easily when used, in particular, with a hosting service like GitHub.

  • COLTON OGDEN: Sure.

  • And I know we use GitHub all the time in CS50.

  • But for folks unfamiliar, do we want to show them what GitHub looks like

  • and maybe just give a couple of sentences of what GitHub itself is?

  • I'm going to pull up our other view here just so we can see.

  • That's actually your-- that is your computer?

  • KAREEM ZIDANE: That's my computer here.

  • COLTON OGDEN: Perfect.

  • KAREEM ZIDANE: And this is how GitHub looks like.

  • GitHub is a hosting service.

  • We're going to talk a little bit about GitHub later,

  • but this is what GitHub looks like.

  • If you don't really have a GitHub account

  • you should probably go ahead and create one.

  • Let me sign out of mine here.

  • And if the internet helps, we go to github.com/join you should be able

  • to create a new account if you don't have one.

  • COLTON OGDEN: OK.

  • And so git is what we use at the command line or whatever.

  • The actual tool.

  • And then GitHub is where we can push our code

  • and store it and let other people see it and work on it, right?

  • KAREEM ZIDANE: True.

  • We're going to discuss this in a bit more detail later on.

  • Git, yes, is mainly a command line tool, but it also

  • has graphical user interfaces if you'd like to use a graphical user interface.

  • I personally use it on the command line, which is easier for me.

  • But you can definitely download a graphical user interface for it

  • and use it.

  • COLTON OGDEN: OK, cool.

  • Well, let's get started.

  • KAREEM ZIDANE: So the first thing that we need to do

  • is, of course, get git installed.

  • COLTON OGDEN: Hi, Kareem and Colton.

  • Hi, Elias.

  • Good to see you again from Morocco.

  • KAREEM ZIDANE: Thank you so much.

  • COLTON OGDEN: Why don't you read--

  • I can't see what the--

  • it's in blue text.

  • Irene says-- why don't you read Irene's message there too?

  • KAREEM ZIDANE: If I'm not mistaken, if I recall correctly,

  • her name should be pronounced as I-re-neh.

  • COLTON OGDEN: Oh, I-re-neh.

  • KAREEM ZIDANE: Yeah, but maybe--

  • please correct me if I'm wrong.

  • COLTON OGDEN: TIL.

  • KAREEM ZIDANE: This is really exciting for me

  • as well because this is actually my first ever livestream.

  • I've never been on a livestream before, so this is exclusive to you, Colton.

  • COLTON OGDEN: Oh, yeah.

  • This is true.

  • Irene basically said, Kareem the dream stream on screen.

  • KAREEM ZIDANE: Oh, my god.

  • COLTON OGDEN: I'm just really building it up.

  • KAREEM ZIDANE: Why did you start this?

  • COLTON OGDEN: Hi, Kareem, good to see you here.

  • Hi, Colton.

  • Hi, Irene.

  • Good to see you.

  • Or I-re-neh, if Kareem's pronunciation is correct.

  • KAREEM ZIDANE: Yup.

  • COLTON OGDEN: OK, somebody from Egypt.

  • KAREEM ZIDANE: Oh, cool.

  • Great, Hi, good to see you.

  • I can't see the username quite well.

  • [INAUDIBLE] I think I know.

  • I think I know him.

  • [? Muhammad ?] [INAUDIBLE].

  • All right, that's great.

  • Hello from Spain.

  • We have different people from all around the world.

  • COLTON OGDEN: And [INAUDIBLE] is as regular as well.

  • He's been on the game [INAUDIBLE].

  • Good to see you.

  • Thanks for coming in again today.

  • All right.

  • KAREEM ZIDANE: So the first thing that we

  • need to do in this case is, of course, download and install git.

  • Git has installers for at least Mac OS, Windows, and Linux.

  • I'm going to be using the Linux, specifically Ubuntu 18.10.

  • I don't know.

  • Maybe 18.10.

  • I don't think it should make a difference how you install git

  • on this, on Ubuntu in general.

  • So the first thing that you need to do, if you haven't done this already,

  • is to download and install git.

  • Maybe follow the documentation here on how to do that.

  • In my case, I'm just going to apt-get update to make sure that I have

  • the latest--

  • to make sure that my package manager knows about the latest versions

  • of packages that are available.

  • apt-get install git.

  • This is how I think you would install git on Linux.

  • Yes, I'm sure I want to install all these dependencies, excuse me.

  • And once this is done to verify that git is installed,

  • you can just to git --version and it should tell you that you have git.

  • COLTON OGDEN: By the way, just included the chat box.

  • We ere missing the chat box there in the video.

  • KAREEM ZIDANE: OK, that's great.

  • So now that we have git installed, the first thing that we want to do

  • is create a git repository or initialize a git repository to be specific.

  • And I think there are two cases here.

  • The first case is you are starting from scratch

  • and you have an empty directory.

  • Let's call this project or my project or whatever.

  • And you can just go inside of this directory using the cd command.

  • And the way to initialize this git repository or project--

  • or in other words say, hey, git, I want you

  • to track the changes in this project--

  • is by running git init.

  • And git should reply, initializing the git repository in root,

  • workspace, the path to your project.

  • and then creates this .git directory that we're not going to really worry

  • about it too much for now.

  • But this is how we initialize a git project.

  • This should work pretty much the same if you already

  • have a project in this case.

  • So let me try to remove this project first, and I do have a thing froshims.

  • I'm going to use David's froshims example from lecture.

  • So I'm just going to copy this recursively here.

  • Now I'm going to get in it to initialize this project.

  • And now we have git tracking this project or this folder.

  • A question that you would find yourself asking pretty frequently

  • is hey, git, what's the status of this project.

  • What changed, what didn't change, and so on?

  • COLTON OGDEN: I lose track, definitely, all the time if I'm making changes

  • to files over and over again.

  • KAREEM ZIDANE: Yeah.

  • So the way to do this is actually literally by running git status.

  • And in this case, git you tell us what changed and what not in this case.

  • COLTON OGDEN: So if we installed git, we run git init first,

  • which basically says, OK, this is a new git project.

  • I want to be able to start tracking the files.

  • And then, once I start editing, then it can call git status

  • and then that will show me basically what I've made changes to.

  • KAREEM ZIDANE: Yeah, you can pretty much run git status at any point.

  • You don't have to make a change.

  • You can just [INAUDIBLE].

  • I run git status all the time to see if I made a change or not at some point.

  • COLTON OGDEN: Sure.

  • We've got a couple of messages in the chat.

  • It says I-re-neh--

  • I got to get used to pronouncing that.

  • Kareem pronounced it perfectly, I-re-neh,

  • but I'm using the English pronunciation too.

  • I'll try to remember that.

  • It's going to take me a little bit of breaking the habit.

  • And then, [INAUDIBLE] says we can use the [INAUDIBLE] IDE

  • and not worry about the installation process.

  • That's true, right?

  • KAREEM ZIDANE: Yeah, that's a great point.

  • Git is already preinstalled inside of the CS50 IDE,

  • so if you want to get started right away without having

  • to worry about installing this, you can just go to CS50 and login

  • into your workspace.

  • COLTON OGDEN: And [INAUDIBLE] I think is maybe alluding to the same thing.

  • He says, glad to be here.

  • Downloaded it, yet to install on Windows 10.

  • He opened the IDE for now.

  • So I think maybe he's saying he wasn't able to get it all working on Windows

  • 10 and he's using the CS50 IDE.

  • KAREEM ZIDANE: Yeah, that's great.

  • If you want to follow along right now and you don't have it installed,

  • feel free, of course, to log into your CS50 IDE

  • and you should have git installed there.

  • COLTON OGDEN: OK, cool.

  • So we talked about installing it, we talked about git init

  • and then git status.

  • So now that we be able to track, I'm guessing it's a--

  • KAREEM ZIDANE: So the first thing that I wanted

  • to explain before we go deeper into this is

  • to understand the difference between these three main parts.

  • Can we see all this?

  • COLTON OGDEN: I think we can switch to--

  • oh, I don't know if we have just a--

  • I can move us.

  • I can move us.

  • KAREEM ZIDANE: I can also resize my window [INAUDIBLE]..

  • COLTON OGDEN: Let me go to the editor and then just do a little bit of this.

  • Just move us right off screen.

  • And then I'll move the chat box as well.

  • Let's try that.

  • KAREEM ZIDANE: OK.

  • This sounds great.

  • So this image is from the official git documentation,

  • and it shows us the difference between three areas or three

  • states in which the files can be in.

  • The first one of them on the left is the working directory,

  • and this is pretty much our folder where we make changes to our file.

  • There is a second place called the staging area,

  • or the index as it's sometimes called, and this

  • is where we say mark these changes.

  • Mark these changes to be committed in the next commit, or save these changes

  • or mark them.

  • Hey, I'm going to save a snapshot of this when I do [INAUDIBLE] next time.

  • And then finally, we have the git repository

  • is where we have these changes actually saved.

  • So it's important to understand the difference between these three areas.

  • So once again, just quickly to recap.

  • Working directory is where we have our files, where we modify our files when

  • we work on our project.

  • Staging area is where we mark changes, and the git repository

  • is where our changes are saved.

  • COLTON OGDEN: So we stage the files but they're not actually saved--

  • git's not saving them permanently.

  • It's kind of like I'm putting down some files to potentially save later

  • as being part of my .git folder.