In this movie we are going to start making edits to our explore_california web site,
to get a feel for what real world edits might look like.
So to start us off, we are going to edit the 24-hour support contact number.
We come down here to the bottom of the page.
You will see at the Contact, this is 24 hour support number at the bottom, and
it's listed as being 4315. We are going to change that to 4314.
Now it's at the bottom of every single HTML page in the footer.
It's also listed in the text sometimes like on the Contact page.
It's listed here on a paragraph of text. So we are going to want to change all of those.
So you could go in and open up each one those files and change them one by one.
I am going to use TextMate to edit the project altogether.
So I can drive the folder on top of TextMate, it opens it up as a project, and
the big advantage to doing that is then I can do Find in Project and find all
occurrences of 4315 in the entire project.
Double-check them, make sure that they are all relevant, that none of them are
something besides the support phone number, and then I can change them all to
4314 using Replace All.
Now it's changed them all, but it hasn't saved those changes to disk yet.
I have to use Save All to do that.
Now all those changes are saved in my working directory.
Not in a staging index, not in the repository, just in my working directory.
If we come back over here, and we do git status, you will see that it lists now
all those files as having been changed.
Now before we commit them I want to show you something, which is we saw how
we could use git diff before, and we saw we could use it with single file like contact.html.
Let's take a look at that diff. Notice a couple of things.
Notice first of all that it gives us two chunks that were changed here.
One chunk up above, one below.
This one is showing us starting at line 71, seven lines.
So here is line 71, countdown seven lines.
Now you will actually count eight lines, because this line is in the minus
section, while this line is in the plus section and the plus section is showing
me from line 71, seven lines.
So this line here that's changed is showing twice.
Seven lines one of them is repeated twice making eight lines total.
Same thing down here.
Now these line numbers are very useful, because then we can look over here in
our contact file, and we can scroll down until we get to line 71, and that's
where our change is, or the context for our change is, if you are on this page.
If you're currently on a tour, is the text that actually changed, that's right here.
If you're on a tour.
So here is the support phone number that's the bit of text that was changed.
Now notice that doesn't show that bit of text is way off over here on the side.
If I keep stretching out there, it will try and expand until I get there, but
it's such a long line that it won't get there.
It's a good reason to try and keep your line short if you can and for HTML it
doesn't really care about the line breaks. It's not whitespace dependent.
However, the another trick that you can do is that what we are looking at here
is actually being run through what's called a pager.
It's showing me pages of results and in fact if I scroll this up like this, you
can see that it's now asking me.
Here, it's prompting me, waiting for me to hit the spacebar to show me the rest
of the results, and I can use F and B to go forwards and backwards through those results.
What this is the less pager that's built into UNIX.
So I'm using the less pager to see these results.
The less pager has a feature where I can either start it up using the -R
command, and you can set that in your global configuration or while I'm inside
of it I can press the minus key and then Shift+S and then hit Return, and it
will fold those long lines.
So to wrap it around instead of having the lines be truncated.
And if I want to switch it back -S and Return chops the long lines instead.
Now as I said that is something you can use a configuration for in your config
file if you wanted to always be that way.
So it's really up to you and how you like to work.
Notice here we can see the change between these lines really easily, 4315
got changed to 4314. I am going to hit Quit.
We are going to do the git diff again just like we did before, but this time I
am going to add in an option here which is color-words.
So git diff with the option color-words contact.html.
Now notice that it comes up, and it gives me that same information, but instead
of having two separate lines it gave me a different format, and it put the
change here side by side.
This is just one of many options that you can use with a diff to get it to show
you information in a different way.
So if you prefer instead of saying one line above the other, you prefer having
it actually color the output for you so you can see the difference between them,
you can use the color-words option. So we have seen enough of that.
We are ready to go back here, and we are ready to make our commit.
Right now, these are in our working directory, we haven't staged them yet.
We know that we would use git add, and then we could do them one at a time or we
could just use git add. and put all of them into the index.
I want to instead show you another way to do it. It's a shortcut.
From here, we can do git commit with the -a option, that's telling it to add it
to the staging index and then commit it. All in one big move.
So it's going to add it and commit it and allow us to skip that process of
actually having to say add them one by one.
Now there are couples of big caveats to this, and you need to be careful about them.
The first is that, of course, this grabs everything that is in your working directory.
So if there were some things that you didn't want to include in the change,
they're going to get pushed up there as well.
The second caveat, is that files that are not tracked, or files that are being
deleted, do not get included in this.
So it works well for modifications, but for new files and deleted files
it doesn't work well.
In this case, I'm only making modifications I know that as soon as I finish
doing the add of everything, I am going to commit it all,
it's okay to do the shortcut. And then I am going to use the -am option after
it is well to provide the message, and I am going to say, Changed 24 hour
support number to 4314. So there we are.
I have committed my change, git status, you can see that my working directory is clean.
It went right from my working directory, right on past the staging index, and
into the repository, git log will show us that second commit.
So again you should use that -a option very carefully.