Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
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 the last movie we saw how we could use git diff to get details about the changes that were in our working directory. In this movie we are going to see how we can do the same thing with our staging index. Now the first thing, of course, we need to do is put something in our staging index, so let's do that with first_file.txt. We know how to do that with git add first_file.txt, now it's in our staging index. Git status will show us, first_file, those changes are now staged. The changes to third_file.txt are just in our working directory.
If we were to do a git diff now, it would just report the changes that are in our working directory. So when I told you earlier that it was comparing your working directory with the repository, that's not quite true, it's actually comparing it against the staging index and the repository. So it's things that are unique, things that are different about the working directory only. So what about those changes for first_file, how do we see those? Well, we do the same thing using git diff, but now we pass in another option, which is staged, git diff --staged.
It's the option to diff that tells it to look at what's in the staging index and compare that against the repository. So now you can see we're only seeing changes that we made to first_file.txt. So git diff by itself will return the changes that are in the working directory. I also just want to note for you that git diff --staged in versions before 1.6 of Git, it was actually called cached. But that wasn't as clear to people and so they standardized on calling it the staging index, and it became called staged.
Now, you should be working with version 1.7 of Git or later, so it should be staged for you, but cached also still works, it does the same thing, it returns the exact same information. But we are going to stick with using staged. So now just like before, of course, if we git add our third_file, now git status, you can see that both of those files are now in the staging index and git diff returns no changes, git diff --staged will show us both sets of changes.
So the last thing we want to do is let's go ahead and just save our changes. So we've got these to be committed already, these are in our staging index, so we're just going to do git commit, and let's just give it a simple message, we'll say Minor text edits. So there it is committed, now if we do git status, our working directory is clean again.
Find answers to the most frequently asked questions about Git Essential Training.
Here are the FAQs that matched your search "":
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.