Git:文件“已更改但未更新”

时间:2011-01-27 02:25:37

标签: 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#

既然他们已被添加,为什么他们不是“改变承诺”?

3 个答案:

答案 0 :(得分:24)

每次使用git addgit commit -a而不是普通git commit --all时,您必须使用git commit

来自Git docs

-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的跟踪更改此文件。

答案 1 :(得分:6)

每次修改文件时,都必须使用git add添加它才能提交它,即使你在开头添加它也是如此。

答案 2 :(得分:3)

git add <file>将“更改”添加到本地提交计划中,如果未添加这些更改,则不会提交它们。

为什么呢?这就是git的工作流程,就像任何可以解释的术语一样,也许你已经习惯了SVN的add概念,试图放弃你的假设并学习git如何做事。

相关问题