Git:文件“已更改但未更新”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4812096/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git: file "changed but not updated"
提问by Nate Reed
What does "Changed but not updated mean"? These files are in git, they've been modified but when I run "git status," these changes appear under "Changed but not updated" instead of "Changes to be commited."
“已更改但未更新”是什么意思?这些文件在 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#
Since they've already been added why aren't they "Changes to committed"?
既然它们已经被添加,为什么它们不是“已提交的更改”?
回答by KitsuneYMG
You have to use git add
every time ORuse git commit -a
or git commit --all
instead of plain git commit
.
您必须git add
每次都使用OR使用git commit -a
orgit commit --all
代替普通git commit
.
from Git docs:
来自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
is basically the "take notice of this file/directory" command. Not CVS's or subversion's track changes to this file.
add
基本上是“注意这个文件/目录”命令。不是 CVS 或 subversion 对这个文件的跟踪更改。
回答by Simon
Every time you modify a file, you have to add it using git add
to be able to commit it, even if you did add it at the beginning.
每次修改文件时,您都必须使用添加它git add
才能提交它,即使您在开始时添加了它。
回答by ocodo
The git add <file>
adds the 'changes' to your local commit schedule, if those changes aren't added, then they aren't committed.
在git add <file>
增加了“变化”到本地提交的时间表,如果不添加这些变化,那么他们都不敢承诺。
Why? This is git's workflow, just like anything there is terminology that is open to interpretation, perhaps you're used to SVN's idea of add
, try to forego what you assume and learn how git does things.
为什么?这是 git 的工作流程,就像任何有可以解释的术语一样,也许您已经习惯了 SVN 的想法add
,尝试放弃您的假设并学习 git 如何做事。