Git:文件"已更改但未更新"

Nat*_*eed 28 git

什么"改变但没有更新意味着什么"?这些文件是git,它们已被修改,但是当我运行"git status"时,这些更改显示在"已更改但未更新"下,而不是"要提交的更改".

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
# modified:   breakouts/views.py
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified:   templates/registration/login.html
# modified:   templates/registration/registration.html

# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# context_processors.py
# static/#css.css#
Run Code Online (Sandbox Code Playgroud)

既然他们已经被添加,他们为什么不"改变承诺"?

Kit*_*YMG 24

你必须使用git add每次使用git commit -agit commit --all平原代替git commit.

来自Git文档:

-a
--all
  Tell the command to automatically stage files that have been modified
  and deleted, but new files you have not told git about are not affected.

add基本上是"注意这个文件/目录"命令.不是CVS或subversion的跟踪更改此文件.

  • 请注意,在较新的git版本(> 1.8)中,评论"已更改但未更新"被查询为"未提交的更改" (2认同)

Sim*_*mon 6

每次修改文件时,都必须使用它来添加git add它,即使你在开头添加它也是如此.