Viewers: in countries Watching now:
The course shows how to use Git, the popular open-source version control software, to manage changes to source code and text files. Using a step-by-step approach, author Kevin Skoglund presents the commands that enable efficient code management and reveals the fundamental concepts behind version control systems and the Git architecture. Discover how to track changes to files in a repository, review previous edits, and compare versions of a file; create branches to test new ideas without altering the main project; and merge those changes into the project if they work out. The course begins by demonstrating version control in a single-user, standalone context, before exploring how remote repositories allow users to collaborate on projects effectively.
In this movie, we're going to learn how to create a branch. To begin with, let's start by looking at our current branch. The way you can see all the branches in our local repository is git branch. And it's just by itself git branch will show us a list of the branches that we have on our local machine. I only have one, and it is master, the default branch. And you can see there is an asterisk next to it. That lets you know that that's the branch that we're on now. We refer to that as the current branch or the currently checked out branch. You may remember from our discussion about the HEAD pointer that the reference for the HEAD pointer is stored in the .git folder.
So cat .git/HEAD, and inside there what that file contains is a reference to one of the branches, because HEAD always points to the tip of a branch. So the HEAD says all right, here is the branch that I'm on now, and then we can go in that folder to find out what the actual tip is. I can do ls -la .git/refs/HEADs, let's just do that, let's not do master, and we'll see a directory listing of all the branches that are listed there.
When we add new branches this is where they show up, it adds a new reference in the HEADs folder. And if we take a look at what's in that, .git/refs/heads /master, you can see that that contains the SHA that points to a commit, that is the tip of the current branch --oneline, so there it is. So you can see that it points to this one right here. So now that we have a good foundation for what's going on with our existing branch, let's try creating a new branch. We do that with the git branch command again, but this time, we just provide the name of the new branch.
I'm going to call mine new feature, you can call it anything you want. There can't be any spaces in there, and you will want to stay away from punctuation. You want to keep it simple with basic letters, numbers, and underscores. So git branch new_feature, I hit Return, and it created the branch for me. How do I know that it did that? Well, git branch, there it is. I'm still on the master branch. That's still the one that's checked out, the one that I'm working on. HEAD still points to master right now. We're going to talk about switching branches in the next movie. Before we do though, let's just go and take a look at what was created in our git folder; ls -la .git/refs/heads, and there we see it.
Now there's a new reference for it in the refs/heads for new feature. What do you think that points to? .git/refs/heads/new_ feature, it points to the exact same commit right now, because I haven't made any other changes. It still points to the same commit. They now have two branches pointing at the same commit. Once we start making changes to each of those and making new commits, well then those values will change. Let's take a look at .git/HEAD, and we'll see that it points to master still, that's still the branch that we've checked out.
In the next movie, we'll talk about how we switch to the new branch.
Find answers to the most frequently asked questions about Git Essential Training .
Here are the FAQs that matched your search "" :
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
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.