Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende More about Tracking Files | Introducción a Git
Git Essentials

More about Tracking Files

Desliza para mostrar el menú

When working with Git, files in your project directory can be either tracked or untracked. Tracked files are included in snapshots (future commits), while untracked files are not. Newly created files are typically untracked until added to the staging area.

Tracked files can exist in three states:

  • Modified: changes have been made, but Git has not stored them yet;
  • Staged: changes are prepared to be committed and included in the next snapshot;
  • Committed: changes are saved in a snapshot inside the .git directory.

Use the following image to illustrate these states clearly.

Files classification
Note
Note

If a file is already tracked and changes are made to it, you must run the git add command to stage those modifications.

Modify the test.txt file using the following command:

echo "Never give up" >> test.txt

The >> operator appends the text enclosed in double or single quotes to an existing file, in this case test.txt. The text is added at the end of the file on a new line.

Modifying the file

Now the file has a modified status. Use the git add, git status, and git commit commands to stage the change, check the status of the working tree and staging area, and commit the change, respectively:

git add test.txt
git status
git commit -m "Add a new line"
Staging and committing the changes

As you can see, the changes are now staged, and a new snapshot of the project has been created by committing the staged changes.

question-icon

Suppose we have a file named preprocessing.py. Your task is to put the actions with the respective commands in the correct order, so that the changes in this file will be committed.

1.
2.

Haz clic o arrastra y suelta elementos y completa los espacios

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 9

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Sección 1. Capítulo 9
some-alt