September 24, 2018
How To Create a New Project at GitHub
Mitchell Wright

After working through this video, you'll be able to create a new project at GitHub, clone it to your computer, make changes to it, and push those changes back to GitHub. Let's start by creating a new repository. I create a new repository by starting at GitHub. I've logged into my Erica student account. And I click 'Start a Project'. GitHub asked me to name the new repository and add a description.

I'm going to name my repository FirstRepo. I'm going to skip the description for now. It's an optional thing. And I'm going to keep the repository public, which means that anybody can see it who visits my account. I'm also going to check initialize this repository with the README. This adds a single README file. And by giving some content to the repository when I create it, it means I can start using the repository right away.

I'm going to just leave the rest of the options alone and click 'Create Repository'. And there I have it. Here's my first repository. It consists of one file, which is this README file. And on a repository, whatever you have in your README file, is automatically shown on the front page of the repo. Okay. I'm done over here for now. Next, I'm gonna go to my computer and copy it to my computer where I can make changes, work on my project, and then start pushing those changes back here to GitHub.


Now that I created my first repository, I want to work on it at my computer. So what I need to do is get a special URL called a git clone URL that I will use to copy the repository to my system. There's a 'Clone' or 'Download' button right here. I click it. This opens this little mini window. And here is a URL. I copy it to my system paste board. And now I can use that URL to do my clone operation.

Here I am at the terminal. I'm on my computer, and I'm going to go to my desktop. Let me confirm that I'm there, which I am. And now I'm going to issue my git clone command. Git, clone, and I paste the URL, which will always end with .git.

And when I press Return, Git does the clone operation, creating a new folder directory called FirstRepo on my desktop. I'm going to go into that repository by changing directories, cd FirstRepo. And now when I look, I see the file that's markdown file that was created when I created my repository here back at GitHub.

I can now work on this repository, and I can add files. I can change files. I can do all sorts of things that I need to. And each time I want to create a save point, I can do that as well so that I am using version control's safety features. And I'll show you how to do that next.

Adding Content

Now that I have this new repo, I want to add some content to it. And I don't wanna make you sit here while I create an entire project. So I have a few files that I've already set up that are ready to be put into this project.

So the first thing I'm going to do is open the folder that is associated with this project so I can use some drag-and-drop. And here is my README file, which is the only thing right now in this folder. Then here's my project, which is just a hello world project. And I'm gonna copy it into this folder.

And now when I do ls, you can see that I now have three files in here. But Git doesn't know about the Makefile or hello.c. So I have to tell it by tracking these two files. And I do that by saying git add Makefile hello.c. And it doesn't give me any feedback when I do that. But I know that I've added them. And the second step is first you track them, then you make a commit, and then you can push your work up to GitHub. So I've done the tracking. I've done the add.

Next thing is I'm gonna commit, git commit. And you always have to give a message with commit. And my message today is going to be, "Added hello world sources." And this time, I do get some feedback. This is much more helpful. It tells me that I created two files, Makefile and hello. And of these 2 files, there are 12 insertions. In other words, between the 2 files, there are 12 lines in the files. So I did add. I did commit.

The last thing I need to do in order to update my content up here at GitHub is I need to push it from my computer to GitHub. And I do that with git push. And when I do that, it prompts me for my username, which is erica-student. And it prompts me for my password. And here, it writes the objects out to GitHub. And if I reload this page now, you'll see that I now have three files here instead of one. And the timestamps for both of these are just a minute ago.

And here's my Makefile, which basically just compiles hello.c. And here's the source of hello.c, which says hello world because that's very traditional. So I now have a repository that anybody can download. It's not a very good repository. It's certainly not a very well-documented repository. But anybody can download it, compile it, and run

So what I've done here is that I have created a new repository. I've cloned it to my computer. I have added content. I've then tracked that content, made a commit, and pushed it back to GitHub.

Making Changes

Let's say I want to make a second change now. A good opportunity for this is updating that README file, which is a really pretty terrible README file. So I'm going to open that file in TextEdit, open -e And here's the file.

I'm going to change the name from FirstRepo to Hello World. Compile this simple C program with make hello to create a friendly "Hello World" app for your command line. Okay. I think that sounds pretty good. I've made my change. And I know the file is already being tracked. So, theoretically, I should just be able to commit it.

Let me try that and let's see what happens, git commit -m "Edited README" Oh, no, my changes were not staged for commit. I modified README, but there were no changes added to my commit. And the reason is that I did not tell git very specifically that README had to be added to this commit. So I have to track it again. I have to say git add then git commit -m "Edited README" And now this time, it accepts the commit, and now I can push, git push.

Again, I enter my username, erica-student. And this time, it pushed the changes. And I check that by going over to GitHub. I reload and now you can see that the README has been updated properly. Every time you change, you must add each file that has been changed. And only then can you commit and push your changes.

You've now seen the basics on how to create a simple project hosted at GitHub. You start at GitHub and create a repository. Don't forget the check box for the README. It will help create a repository with the simplest material already added to it.

Clone the repository to your computer so you can work on it there. You develop your project making sure to commit after making major changes and then you push those changes to the remote host, which in this case is GitHub. You repeat this develop commit push cycle as often as needed to ensure that your repository is up-to-date and shows your latest work.

Now it's your turn. Review some of the concepts from this video by creating your own repository at GitHub. Make sure to add a README file so you'll have some initial content to work with. Clone the repository to your computer and then make changes. Track and commit your changes and push those changes back out to GitHub. Make sure to explore your commit history on GitHub so you can see how version control interacted with your changes. This is a great way to better understand version control and see how your history works with real projects.