Contenido del Curso
Git Essentials
Git Essentials
More about Tracking Files
As we discussed previously, when we work with Git, the files in our project directory can either be tracked or untracked. While tracked files are part of the snapshots (future commits), untracked files are not. Newly created files, for example, are usually untracked until they are added to the staging area.
Speaking of tracked files, they can be in one of the three possible states:
- modified (certain changes are made to the file, but Git doesn't store them yet);
- staged (the changes are ready to be committed and will be a part of the snapshot);
- committed (the changes are stored in a snapshot in the
.git
directory).
Let’s take a look at an image to make things clear:
Note
If our file is already tracked and we made some changes to it, we will still have to run the
git add
command to stage these changes.
Let’s now modify our test.txt
file via the following command:
The >>
operator appends the text enclosed in the double quotes (or single quotes) to an existing file, which in our case is test.txt
. The text is added to the end of the file on a new line.
Now, our file has a modified status. We will then use the git add
, git status
and git commit
commands to stage this change, check the status of our working tree and staging area and commit the change, respectively:
As you can see, we have now staged our changes and created a new snapshot of our project via committing the staged changed.
¡Gracias por tus comentarios!