Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
More about Tracking Files | Introduction to Git
course content

Course Content

Git Essentials

More about Tracking FilesMore 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:

Files classification

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.

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.

Click or drag`n`drop items and fill in the blanks

Everything was clear?

Section 1. Chapter 9
course content

Course Content

Git Essentials

More about Tracking FilesMore 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:

Files classification

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.

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.

Click or drag`n`drop items and fill in the blanks

Everything was clear?

Section 1. Chapter 9
some-alt