Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In the last movie we reviewed how we add files to our Git repository. Now what we want to see is how to edit files and how to Git works with those edits. I have my git project, and I have my three files here, let's make some edits to one of these files. So let's pop up in first_file.txt, it's called, This is the first file that I added to my project. So we've made an edit to it, let's save our change and close it. So now that change has been made to first_file.txt.
Now when we come back over to our command line we say git status now it comes up and it tells me, owe something is changed. Changes that are not staged for commit essentially just changes, and it tells me you've modified first_file.txt. Remember before I said there were untracked files, this is different. It's telling us about changes and tells us what those changes are, you've modified first_file.txt, if you want to add it, Git add it with add it, and then it tell us how we can discard those changes, which we will take a look at a little later.
Adding it is exactly the same process for a new file versus a changed file. Essentially it's the process of moving it from our working directory into the staging directory, git add first_file.txt. It will now add that change to our staging directory, git status, clear it so you can see it. Now it says changes to be committed is the modified file first_file.txt. Now before we make that change, and we commit that, let's make some more changes, second_file.
This is the second file that I added to my project, and let's go ahead and open up third_file. This is the third file that I added to my project. So now we've got all three of those, let's now take a look at git status and see what's going on now. It's got still the thing that I changed in the staging directory first_file still there ready to be committed it also notes the new changes that I made those are new in the staging directory yet.
If I want to put those in the staging directory if I want to package them as this next commit then I need to add them. So let's say that I want to do that with the second file git add second_file.txt. Now if I do git status, you'll see that two files are listed as being modified, ready to be committed, one file is still in my working directory, I haven't added it to my staging directory yet it just notes the fact that it's changed, that it's different from what's in the repository. So let's do a git commit with a message, and we're going to say made changes to first and second files.
So now it makes note of that change git status, clear the screen so you can see it, and you'll see that it's still tracking the changes for that third file, it took those first two, packaged them up together as a snap shot, sent them to my repository, git log, and we see there it is. Now here is the new commit that it just made. So that's all there is to being able to add files and edit files, it's the same process for both of them. We can say git status, and we can see the changes git add, and we can then put the file name that we want to add--doesn't matter if it's a new file or an edited file--and then finally git commit with the commit message telling it, Modified the text of the third file, and now it's in the repository as well just like that git status, git add, git commit.
These are the basic steps that we're going to be using with Git. Now what if before you made the commit you wanted to remind yourself what did you change any to these files maybe you were surprised that one of them came up as being changed. How can we see what those changes are? We'll look at that in the next movie.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101920 Viewers
61 Video lessons · 88645 Viewers
71 Video lessons · 72448 Viewers
56 Video lessons · 104146 Viewers
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.
Your file was successfully uploaded.