E
E
Evgeny Ivanov2021-06-09 12:51:40
git
Evgeny Ivanov, 2021-06-09 12:51:40

What is the difference between Changes not staged for commit and Untracked files (git add command)?

I study git.
There was a question about Changes not staged for commit, Untracked files and the git add command.
(do not consider the question of aliases that allow committing with one command) The

question is simple, but here is the misunderstanding:

I created the file file1.txt
git status - Untracked files: file1.txt
git add file.txt
Changes to be committed: file1.txt
git commit. ..
All is well. Added, committed.

Next, I changed the file file1.txt
git status - Changes not staged for commit: file1.txt
That is, it must be added again git add - clearly.

Next I created a file file3.txt
git status - Untracked files: file3.txt

Total git add adds to the index and Changes not staged for commit and Untracked files.
And what's the difference then?
Both a new file and an existing one with changes cannot be committed without git add.

What is the point of dividing them into Changes not staged for commit and Untracked files?
That there are new changes in the files, that there is a new file.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Zhivagin, 2021-06-09
@Krasnodar_etc

Untracked files - the file has not yet been added to the repository, changes in it are not tracked, git sees only the fact that a new file with code has appeared. You can add such files to .gitignore and they will not get into the repository, unlike tracked files
Changes not staged for commit - changes in these files have not yet been added to the index for the next commit.
It's just a logical separation of entities. For git add .no difference

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question