Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions book/02-git-basics/sections/recording-changes.asc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Remember that each file in your working directory can be in one of two states: _
Tracked files are files that were in the last snapshot; they can be unmodified, modified, or staged.
In short, tracked files are files that Git knows about.

Untracked files are everything else any files in your working directory that were not in your last snapshot and are not in your staging area.
Untracked files are everything else -- any files in your working directory that were not in your last snapshot and are not in your staging area.
When you first clone a repository, all of your files will be tracked and unmodified because Git just checked them out and you haven't edited anything.

As you edit files, Git sees them as modified, because you've changed them since your last commit.
Expand All @@ -30,7 +30,7 @@ Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
----

This means you have a clean working directory in other words, none of your tracked files are modified.
This means you have a clean working directory -- in other words, none of your tracked files are modified.
Git also doesn't see any untracked files, or they would be listed here.
Finally, the command tells you which branch you're on and informs you that it has not diverged from the same branch on the server.
For now, that branch is always ``master'', which is the default; you won't worry about it here.
Expand Down Expand Up @@ -85,7 +85,7 @@ Changes to be committed:

You can tell that it's staged because it's under the ``Changes to be committed'' heading.
If you commit at this point, the version of the file at the time you ran `git add` is what will be in the historical snapshot.
You may recall that when you ran `git init` earlier, you then ran `git add <files>` that was to begin tracking files in your directory.(((git commands, init)))(((git commands, add)))
You may recall that when you ran `git init` earlier, you then ran `git add <files>` -- that was to begin tracking files in your directory.(((git commands, init)))(((git commands, add)))
The `git add` command takes a path name for either a file or a directory; if it's a directory, the command adds all the files in that directory recursively.

==== Staging Modified Files
Expand All @@ -111,10 +111,10 @@ Changes not staged for commit:

----

The `CONTRIBUTING.md` file appears under a section named ``Changes not staged for commit'' which means that a file that is tracked has been modified in the working directory but not yet staged.
The `CONTRIBUTING.md` file appears under a section named ``Changes not staged for commit'' -- which means that a file that is tracked has been modified in the working directory but not yet staged.
To stage it, you run the `git add` command.
`git add` is a multipurpose command you use it to begin tracking new files, to stage files, and to do other things like marking merge-conflicted files as resolved.
It may be helpful to think of it more as ``add this content to the next commit'' rather than ``add this file to the project''.(((git commands, add)))
`git add` is a multipurpose command -- you use it to begin tracking new files, to stage files, and to do other things like marking merge-conflicted files as resolved.
It may be helpful to think of it more as ``add precisely this content to the next commit'' rather than ``add this file to the project''.(((git commands, add)))
Let's run `git add` now to stage the `CONTRIBUTING.md` file, and then run `git status` again:

[source,console]
Expand Down Expand Up @@ -212,7 +212,7 @@ $ cat .gitignore
*~
----

The first line tells Git to ignore any files ending in ``.o'' or ``.a'' object and archive files that may be the product of building your code.
The first line tells Git to ignore any files ending in ``.o'' or ``.a'' -- object and archive files that may be the product of building your code.
The second line tells Git to ignore all files whose names end with a tilde (`~`), which is used by many text editors such as Emacs to mark temporary files.
You may also include a log, tmp, or pid directory; automatically generated documentation; and so on.
Setting up a `.gitignore` file for your new repository before you get going is generally a good idea so you don't accidentally commit files that you really don't want in your Git repository.
Expand Down Expand Up @@ -270,10 +270,10 @@ It is beyond the scope of this book to get into the details of multiple `.gitign
[[_git_diff_staged]]
==== Viewing Your Staged and Unstaged Changes

If the `git status` command is too vague for you you want to know exactly what you changed, not just which files were changed you can use the `git diff` command.(((git commands, diff)))
If the `git status` command is too vague for you -- you want to know exactly what you changed, not just which files were changed -- you can use the `git diff` command.(((git commands, diff)))
We'll cover `git diff` in more detail later, but you'll probably use it most often to answer these two questions: What have you changed but not yet staged?
And what have you staged that you are about to commit?
Although `git status` answers those questions very generally by listing the file names, `git diff` shows you the exact lines added and removed the patch, as it were.
Although `git status` answers those questions very generally by listing the file names, `git diff` shows you the exact lines added and removed -- the patch, as it were.

Let's say you edit and stage the `README` file again and then edit the `CONTRIBUTING.md` file without staging it.
If you run your `git status` command, you once again see something like this:
Expand Down Expand Up @@ -334,7 +334,7 @@ index 0000000..03902a1
+My Project
----

It's important to note that `git diff` by itself doesn't show all changes made since your last commit only changes that are still unstaged.
It's important to note that `git diff` by itself doesn't show all changes made since your last commit -- only changes that are still unstaged.
This can be confusing, because if you've staged all of your changes, `git diff` will give you no output.

For another example, if you stage the `CONTRIBUTING.md` file and then edit it, you can use `git diff` to see the changes in the file that are staged and the changes that are unstaged.
Expand Down Expand Up @@ -409,7 +409,7 @@ Run `git difftool --tool-help` to see what is available on your system.
==== Committing Your Changes

Now that your staging area is set up the way you want it, you can commit your changes.
Remember that anything that is still unstaged any files you have created or modified that you haven't run `git add` on since you edited them won't go into this commit.
Remember that anything that is still unstaged -- any files you have created or modified that you haven't run `git add` on since you edited them -- won't go into this commit.
They will stay as modified files on your disk.
In this case, let's say that the last time you ran `git status`, you saw that everything was staged, so you're ready to commit your changes.(((git commands, status)))
The simplest way to commit is to type `git commit`:(((git commands, commit)))
Expand All @@ -420,7 +420,7 @@ $ git commit
----

Doing so launches your editor of choice.
(This is set by your shell's `EDITOR` environment variable usually vim or emacs, although you can configure it with whatever you want using the `git config --global core.editor` command as you saw in <<_getting_started>>).(((editor, changing default)))(((git commands, config)))
(This is set by your shell's `EDITOR` environment variable -- usually vim or emacs, although you can configure it with whatever you want using the `git config --global core.editor` command as you saw in <<_getting_started>>).(((editor, changing default)))(((git commands, config)))

The editor displays the following text (this example is a Vim screen):

Expand Down Expand Up @@ -572,7 +572,7 @@ This command removes all files whose names end with a `~`.
(((files, moving)))
Unlike many other VCS systems, Git doesn't explicitly track file movement.
If you rename a file in Git, no metadata is stored in Git that tells it you renamed the file.
However, Git is pretty smart about figuring that out after the fact we'll deal with detecting file movement a bit later.
However, Git is pretty smart about figuring that out after the fact -- we'll deal with detecting file movement a bit later.

Thus it's a bit confusing that Git has a `mv` command.
If you want to rename a file in Git, you can run something like:
Expand Down Expand Up @@ -607,5 +607,5 @@ $ git add README
----

Git figures out that it's a rename implicitly, so it doesn't matter if you rename a file that way or with the `mv` command.
The only real difference is that `git mv` is one command instead of three it's a convenience function.
The only real difference is that `git mv` is one command instead of three -- it's a convenience function.
More importantly, you can use any tool you like to rename a file, and address the add/rm later, before you commit.