Join Kevin Skoglund for an in-depth discussion in this video Setting up a GitHub account, part of Git Essential Training.
We're going to start out by setting up a remote repository, and the way we're going to do that is by signing up for an account at GitHub, that's http://github.com. GitHub is the most popular Git host. There are other ones out there, but they're a great one, and I think you should start with them first before you started exploring other options. They offer free and inexpensive hosting plans. Free is going to be great for our purposes when we're just getting started, but then we can also upgrade to very inexpensive plans later on as our needs grow.
And one of the things that I love about GitHub is that not only do they provide reliable hosting for our Git repository, but they also offer many other great features. For example, charts and graphs that show the state of all the different branches and the commits that have been made, or graphs showing the activity on a project over time. Those kinds of bells and whistles make it a really nice choice. Now here I'm on the GitHub site. The design of the page may change over time, they certainly may update their web site after I record this. The thing I want to look for is the Signup and Pricing button, there's one there, and there is a big one down here.
They have a lot of different plans. The one we're going to be picking is the Free for open source plan, which is $0 a month. It's unlimited public repositories and unlimited public collaborators. That means that once we push our code up there to the repository, everyone can see it. People may not be looking at our repository, but if they wanted to, they can. It is browsable. For open source projects that's ideal, but if you want to have a private repository where you can put code that people can't see, let's say you're building a project for a client, it might not be something that you want everyone to be able to see the commits that you're making on behalf of that client.
In that case you would need a private repository, and that's what these other plans offer is different levels of private repositories for you to use. For now we can start with a free account unless you already know that you want to go with one of those others. So create a free account, and then we just have to enter some basic information. Username that we want to use, the Email Address, our Password, and then our Password a second time, and then Create an account. That's really all there is to it. Now it may send you an email and want you to confirm that you are who you say you are and things like that. Go ahead and follow all of those steps, and then sign in when you're finally all set up.
Now do give some thought to your username, because this username is the name the collaborators on projects are going to see as well. Once you've gotten your account created, and you've signed into it, the next thing we want to do is we want to create a new repository. In order to connect to the repository we have to create it first. So on the GitHub site, create the new remote repository. Create a New Repo is right here. If I click that, it will come up and say, what do you want to call this repository? Now you can call it anything you like, it should probably match your project name.
I'm going to call it explore_california. A description here, so we can provide a description, it's completely optional. Let's say Website for Explore California. And then we have a choice, do we want to make it Public so that anyone can see what's in it? We can still choose who can commit to it. They can't necessarily have access to it but they can see it. Or we can choose Private, which means that only we can do it. If I choose Private, then I have to upgrade my account, because I have to go from a free account to a Micro account, if I don't already have that.
If I choose Public, then you don't have to so that's what I'm going to pick. Now the next option we have to decide is do we want to initialize this repository with a README. If you remember back to when we first created our very first repository, the very first step we did was we initialized the repository, and then we made our first commit. So then at that first point we have our first commit in the repository, it's sort of the very basic first step, and it's very common to create that first step by putting a README file in there just to get things started.
So they're offering to do this for you automatically, so you can check that if you want. I'm going to leave it unchecked. It will also add a gitignore file for us if we want. So we can add a gitignore file to the repository, and we can pick, and you can pick based on what kind of project you're going to be doing. It will pull from the repository of gitignore files that we looked at earlier and put those in there for you. So those are two examples of the kinds of nice features that GitHub gives you. I'm not going to do either one of those though, I'm just going to click Create repository. So GitHub created the remote repository on their servers, and then they provide us with some helpful setup instructions.
So we've got Quick setup here, if you've done this kind of thing before, or the steps that we want are down here, they give us two choices. Either create a new repository on the command line or push an existing repository from the command line. Since we have an existing repository, that's the step that we want to follow. Now you'll notice here these steps are basically the steps that we followed early on in order to create the basic first commit of our repository, and the last two steps are basically the same thing once we have an existing repository.
It's also the same thing here, creating the init step that they offered to do for us on the last step. So we've already done it, we could do it ourselves from the command line again, or we can have GitHub do it. But the end result is that we have a repository and what we need to do then is git remote add origin and then this address right here. This address is also up here. If you click HTTP, you'll see the exact one, HTTP, https, that's the one that you want to make sure that you get, not the git@ github one, make sure that you get the HTTP one.
The other one would be if you were logging in via SSH instead of via HTTP. Now don't worry about the exact syntax of this git remote add and git push, because we're going to be talking about those in the next movies.
- Exploring the history of version control
- Installing Git on Mac, Windows, and Linux
- Initializing a repository
- Writing useful commit messages
- Understanding the Git three-tree architecture
- Tracking when files are added, edited, deleted, or moved
- Viewing change sets and comparing versions
- Undoing changes and rolling back to previous versions
- Ignoring changes to select files
- Creating and working with code branches
- Merging branches and resolving merge conflicts
- Stashing changes for later
- Working with hosted repositories and remote branches
- Developing an effective collaboration workflow
Skill Level Beginner
Q: In the Chapter 10 movie "Configuring the command prompt to show the branch," when I type the function "__git_ps1," I do not get the expected result.
A: The function "__git_ps1" was recently moved to a new file, .git-prompt.sh, as described here: https://github.com/git/git/commit/af31a456b4cd38f2630ed8e556e23954f806a3cc.
We will update the video. In the meantime, you may do the same steps you do for .git-completion.bash, but a second time using ".git-prompt.sh" as shown here: https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh.
Q: When I use the code the instructor advises in the above video ("git config --global user.name "Nelda Street"), I still get an "Illegal Instruction" error. I have OS 10.6.8. Am I doing something wrong?
A: The current installer version of git isn't compatible with older Mac OS versions.
1. To add "-mmacosx-version-min=10.6" as described here:https://stackoverflow.com/questions/14268887/what-is-the-illegal-instruction-4-error-and-why-does-mmacosx-version-min-10https://stackoverflow.com/questions/10177038/illegal-instruction-4-shows-up-in-os-x-lion
2. Or to use the version of git that comes with Xcode, or to use homebrew to install git instead.http://superuser.com/questions/697144/installed-git-not-sure-how-to-get-it-working