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.
We now know how to switch between branches in Git, and we also know that the process of doing that is to use the checkout command, and what the checkout command does is it tells Git to go and get the latest version of the branch and to make our working directory look exactly like it. There is one thing that you need to be cautious about with that, which is that your working directory must be clean in order to switch. Actually, mostly clean. We'll talk about that later, but if it's not clean, then Git won't let you do the switch. Let's take a look. Right now, I'm on my shorten title branch, I do git status, you will see that right now my working directory is clean.
Let's make a change. So I'm going to make a change to index.html, open it up, and in the same line that I changed before, I'm going to change the hyphen to be a colon. I am going to save my changes and close it. So now we have an unsaved change, not stage for commit or anything, just sitting in our working directory. Let's try switching to our master branch, git checkout master, just clear my screen so it's at the top. Now it pops up, and it gives us an error, it says, your local changes to the following files would be overwritten by checkout: index.html. Please, commit your changes or stash them before you can switch branches. Aborting.
Git is telling you, sorry, I can't do this, because if I do, if I make your working directory look exactly like master, you're going to lose the changes that you just made. So rather than destructively just blow out your changes, which you might want to keep, you might not have realized that this was going to a problem, Git stops and does the safe thing, and it says you need to deal with this problem first. You have three options at this point. One, you can scrap the changes by checking out the file again. That's git status git checkout -- and the file name.
The second thing you can do is you can commit the changes to the current branch. Once they're committed, they won't get lost anymore. They're stored in Git, we can just switch back and forth between the branches, and it will just switch back and forth between the HEAD of each one of those branches. The third possibility is that we can stash the changes, and we'll talk about the stash a little later on. Basically it's a little pocket that we can put things in and save them until later. We can put them away to a little area that we can pull them back when we're ready. So for now, let's go ahead and just commit this, git commit, and we'll use the -a option to both add it and commit it at the same time, and then give it a message, we'll say, Swap Out - for : in index.html title.
So now, we've made our change, we can now checkout master, no problem. We can checkout our shorten title, and it switches back and forth between those just fine. Now I said it has to be mostly clean, because it doesn't have to be completely clean. It just has to be clean enough that there are no conflicts. So for example, let's say that I put a new file in here, tempfile3.txt, just any file will do. Now if I say git status, we see that we are on our shorten title branch, and you can see that here's the file, tempfile3.txt that's untracked.
If we say git checkout master, it said no problem, I have no problem switching for you. git status, now we're on branch master, still have this untracked file. So that's what I mean when I say mostly clean, we can't have anything that would cause us to lose data if we made the switch.
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.