From the course: Git for System Administration

Creating a GitHub repository - Git Tutorial

From the course: Git for System Administration

Start my 1-month free trial

Creating a GitHub repository

- There are many different ways of having a remote git repository. But one of the most popular is hosting it on GitHub. GitHub is a site that provides free and paid git repository hosting. This allows us to push our files up to remote host without us hosting it ourselves. The free accounts can be public or private, but have limitations on how many users can collaborate. We're going to start by browsing to GitHub.com. To create an account, click on Sign Up in the top right. Now enter your username, email, and password. (keyboard keys clicking) To prove that you're not a bot, you need to solve a problem, which involves rotating an image. Click on Verify, and then rotate the image. Now click on Done. And then scroll down, and click on Create An Account. Now we have to choose a plan. Both accounts let us have an unlimited amount of private and public repositories. This has changed. In the past, if you wanted a private repository, you had to pay. Now both accounts are similar, but the free account limits to number of collaborators. For this course, the free plan is perfectly fine. Click on Free, and then click on Continue. Now, it will ask you a couple of questions about your programming experience, and then what you're planning on using GitHub for. You can put anything you want here. I'm going to click on Host A Project. And then scroll down and click on Submit. Now it will ask you to verify your email address. Once you've done that, you will be taken to the main GitHub screen. Now, we want to create a repository. In the top right-hand corner of the screen, click on "+" symbol, and then select New Repository. For the repository name, type in GitProjectOne. You can add a description if you like. You can also make it public or private. I'm going to chose Private. The next step is to decide if you want to include a README file. Since we already have a repository that we will get files from, let's skip this. We have the files we already need stored locally. If this were a bare repository to be cloned, we might include the README. We can also include pre-configured .gitignore file, but since we've already created one, we'll skip this as well. Now click on Create Repository. Now we're presented with some information. We either create a new repo and the command line, and then add this remote to it, or, if we already have a repo, which we do, we can just add this remote to it, and push our files up to GitHub. Lastly, we could import from another repository, such as Subversion. We're going to choose a second choice. The first line is git remote add origin, followed by our URL. This adds a remote named Origin, with a URL to our GitHub project. There's nothing special about the word origin, we could call it anything. The next line is git push -u origin master. This pushes our files from the master branch, to a remote named Origin. Let's copy both lines onto the clipboard, but leave the web browser open. Now go back to your command line. Make sure you're in your GitProjectOne directory, and then paste both lines. And hit Enter. It will ask you for your username and password. (keyboard keys clicking) This should push the files up to GitHub. If it does not, you'll need to troubleshoot this first. Now let us take a look at what it did. Type in git remote -v. This should show we have one remote called Origin for fetching and for pushing. It is possible that these two could be different, and we'd have one repository to pull files down from, and we'd push to another. Now, let's go back to our browser and click on the project name on the top of the page. If our push went well, we should see all files in our project. We can click on Commits to see what has been done. And then we can click on any of the files to read them.

Contents