Getting Started with Git

Aug 14 2023 · git 2.28, console

Part 1: Getting Started with Git

02. Create a New Repository

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 01. Introduction Next episode: 03. Clone a Repository

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 02. Create a New Repository

Create a repository through GitHub app of the same recipe example that will be shown in video 1 with text files.

Transcript: 02. Create a New Repository

Now that you know what version control and Git is, let’s start working with it by installing the GitHub Desktop app. There are many ways to interact with GitHub from using the command line to dedicated GitHub apps. When you’re starting with Git, it’s best to stick with one so you can get used to it. In this course, we’ll be using the GitHub desktop app. In order to use Git effectively, you don’t have to use the command line.

I’m on a Mac computer, but the steps to install the GitHub app and use it should be similar on your machine. Go to your browser, search for GitHub Desktop app. Download the version you need for your machine. Take the appropriate steps to install it. On the Mac, that’s unzipping and dragging to the Applications folder. Now that it’s installed, you can start building the favorite recipes book we started earlier. Let’s do that by creating a repository. A repository is a collection of all of your project’s files and a revision history of those files, whether that be text files like a readme, source code, or even images of our recipes. To understand how Git works, you don’t have to go through this course with an actual software project. You’ll use text files to simulate a software project, but the concepts are all the same. Click on “Create a new repository” on your hard drive. Enter the name “Recipes Book” for the name of the repository. Give a description of “A book of delicious recipes.” Then, for the path, select where you want this repository to be on your local machine. You can leave the rest of the defaults as is and click “Create repository.” When you install the app for the first time, if you have a GitHub account, you can enter your credentials through preferences so it will sync with your account. If you don’t have an account yet, we’ll show how to set that up later in this course. The first thing you’ll notice in the UI is the navigation bar has our current repository, “Recipes Book.” On the bottom, Git created an initial commit for us when it created the repository, similar to how we named the recipes Google Doc as “Initial Revision.” Let’s add our list of recipes to this repository. Create an empty “recipes.txt” file inside the “recipes-book” directory. Similar to Google Docs, add the same two recipes: “Carnitas Tacos” and “Fried Chicken.” Now go back to the GitHub app. You can see that because Git is tracking the changes to the “recipes-book” directory, which is our “Recipes Book” repository, it recognizes that there is a new file called “recipes.txt” and that it has these two lines added, denoted by the green. Part of the power of source control is not just the ability to go back in time to a previous revision but also to see why a certain change was made. So, it’s important in a real project to give useful messages when you make a change. Enter “Added first two recipes” and select “Commit to main.” This creates a commit to the main branch. We’ll go over both commits and branches in more detail later in this course. But this action is equivalent to making a snapshot like we did in Google Docs. You can see that by clicking on “History.” The first commit shows the initial commit the GitHub app created on our behalf and just added some attributes for our repo. This commit is the more interesting commit because it’s the first addition to the recipe book. You can see the “recipes.txt” file was added, the changes to the file, and the time the file was added to the repo. Now that the repo is created locally, and we made our first addition, we want to share this project with our friend. In order to do that, we need that central data store to hold our repository, and that’s essentially what a remote repository is. It’s a repository that’s stored somewhere else that’s not your local machine. It could be on your company’s network or a cloud service provider like GitHub. If you’re using GitHub, this means you’re using GitHub as the remote repository. It’s storing your code remotely. If you have an account with GitHub, you can click this button to publish your code to GitHub. It’ll ask you to put in your credentials, and you can set the name of the repository. Keep the name and description the same. Make sure to uncheck the code to keep it private in order to make this repo public so others can contribute to it. If you have a GitHub account, you can go to your account and see the new repo you published on GitHub. Similar to the GitHub Desktop app, it has the “recipes.txt” file with the first two recipes of the book. If you don’t have a GitHub account, in the next video, we’ll walk through how to set one up. Then you can rewind the video and push your code to GitHub.