4 min episode 6 of 24
Today, I’ll show you how to get an overview of your local changes.
First, let me start with good news: you don’t have to watch out for anything while you’re working on your project’s files. You can modify, create, delete, rename or move files in any way - and in any application - that you like. You don’t have to obey any rules to please Git…
After some time of working on your project’s files, you might want to know about the current state.
Let’s open Tower’s “Working Copy” view. It lists all of our current local changes in this project. We see that:
- "index.html" and "about.css" were modified
- "error.html" was deleted
- and we’ve also created a new file here - “new_page.html”
So, with this listing, we have an overview of our current changes. These changes are called “local” or “uncommitted” because they haven’t been saved to the repository, yet. You’ll use the Working Copy view countless times every day - so make yourself comfortable with it…
Let’s take a closer look at what exactly was changed in a file.
Simply select a changed file to see a so-called Diff of the exact changes. A Diff visualizes the differences between two versions of a file. In our case, these two versions are the current, modified state of the file and its last committed version, how it looked when we last saved it to the repository.
A diff doesn’t show the complete file from beginning to end: you wouldn’t want to see everything in a 10,000 lines file, when only 2 lines have changed. Instead, it only shows those portions that were actually modified. Such a portion is called a “chunk” (or “hunk”). In addition to the actual changed lines, a chunk also contains a bit of “context”: some (unchanged) lines before and after the modification so you can better understand in what context that change happened.
Each changed line is prepended with either a “+” or a “-” symbol. Minus shows the line as it was in the old version of the file, while plus shows you how the line looks in the new version.
Let’s look at our example:
Here in our first chunk, two lines are prepended with a “+”. Since no counterpart lines with a “-” exist, this means that these lines were added.
Change #2 is just the opposite: we have two lines marked with “-” signs - but no pluses. These lines were deleted.
In change #3, finally, some lines were actually modified: the two “-” lines were changed to look like the two “+” lines below.
Inspecting a diff like this in Tower is absolutely fine - but you can also use an external diff tool for this job. There are lots of free and paid apps on the market. We’ve compiled a couple of suggestions for you in our free online book: …
To use such a tool with Tower, you simply need to select it in Tower’s preferences. Note that some tools need additional command line tools installed. Be sure to read your tool’s documentation for detailed instructions.
Once it’s configured, you can open your diff tool from Tower in many ways (including keyboard shortcuts). Here, as an example, we use an app called Kaleidoscope.
As said, using such a tool is completely a matter of your own preferences - and not mandatory.
Congratulations - now you know how to get an overview of your local changes. In our next videos, we’ll look at how to commit them to the local repository. Thanks for watching - and see you there!