为什么 git 会记住更改,但不让我暂存它们?

发布于 2024-08-26 08:31:51 字数 769 浏览 4 评论 0原文

当我运行 git status 时,我有一个修改列表,但我无法暂存或提交它们。我该如何解决这个问题?

这是在一次巨大的提交中从裸存储库中提取内核模式目录后发生的。

% git status
# On branch master
# 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:   kernelmode/linux-2.6.33/Documentation/IO-mapping.txt
#   ...

$ git add kernelmode/linux-2.6.33/Documentation/IO-mapping.txt

$ git status
# On branch master
# 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:   kernelmode/linux-2.6.33/Documentation/IO-mapping.txt
#   ...

I have a list of modifications when I run git status, but I cannot stage them or commit them. How can I fix this?

This occurred after pulling the kernelmode directory from a bare repository somewhere in one huge commit.

% git status
# On branch master
# 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:   kernelmode/linux-2.6.33/Documentation/IO-mapping.txt
#   ...

$ git add kernelmode/linux-2.6.33/Documentation/IO-mapping.txt

$ git status
# On branch master
# 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:   kernelmode/linux-2.6.33/Documentation/IO-mapping.txt
#   ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天暗了我发光 2024-09-02 08:31:51

git add -u 应该暂存所有修改。

git add -u should stage all your modifications.

最佳男配角 2024-09-02 08:31:51
git add kernelmode/linux-2.6.33/Documentation/IO-mapping.txt

这应该添加您显示为需要暂存的一个文件。

然而,对两级子目录(而不是问题中的三级)的一些实验表明 git add . 应该添加需要添加的所有内容 - 但对您来说,事实并非如此。

git add kernelmode/linux-2.6.33/Documentation/IO-mapping.txt

This should add the one file you show as needing to be staged.

However, some experimentation with two levels of sub-directory (instead of three as in the question) suggests that git add . should be adding everything that needs to be added - and for you, it is not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文