Git status is a bit confusing

Git reports the following status in one of my branches:

# On branch awesome
# Changes to be committed:
# (use "git reset HEAD ..." to unstage)
#
# new file: NEW.txt
#
# Changed but not updated:
# (use "git add ..." to update what will be committed)
#
# modified: NEW.txt
#

This happened because I created NEW.txtand then the command:

git add NEW.txt

and then edited the file. Does this mean that the execution git commitwill lead to the last changes I made to the file, or should I be particularly careful?

+3
source share
3 answers

Git , . , , git add .

+5

Git (). , . , . , , .

, , . commit -a , , .

+9

, git commit, , , git add (, ), . git diff, :

git diff

shows the differences between your working copy and index, and

git diff --cached

shows the differences between index and HEAD. The differences shown git diff --cachedwill be fixed on git commit.

+4
source

Source: https://habr.com/ru/post/1724693/


All Articles