gpt4 book ai didi

git - 无法摆脱 "Changes not staged for commit'

转载 作者:IT王子 更新时间:2023-10-29 00:33:32 25 4
gpt4 key购买 nike

我无法摆脱这种我的存储库似乎被锁定的状态。在重置为 HEAD~1 后,我不断收到有关此单个文件被修改的通知。 “添加”和“checkout ”没有影响。我已取消设置 core.autocrlf 和 core.safecrlf(空)。

请看下面:

$ git --version
git version 1.7.9.6 (Apple Git-31.1)

$ git status

# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: a_file_name.cpp

以下命令(单独运行)没有影响:

$ git checkout -- a_file_name.cpp
$ git reset a_file_name.cpp
$ git add a_file_name.cpp
$ git reset --hard
$ git clean -n
<nothing>
$ git clean -f
<nothing>

$ git status

# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: a_file_name.cpp

然后继续......

我做错了什么?

对下面@Don 的建议的回应 (git rm),没有变化,但事情是这样的:

$ git rm 
error: 'a_file_name.cpp' has local modifications
(use --cached to keep the file, or -f to force removal)
$ git rm -f a_file_name.cpp
rm 'a_file_name.cpp'
$ git status

# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: a_file_name.cpp
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: a_file_name.cpp
#

$ git commit -m"tmp"
[master 2a9e054] tmp
1 file changed, 174 deletions(-)
delete mode 100644 a_file_name.cpp

$ git status
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: a_file_name.cpp
#

差不多回到 sq.1

最佳答案

git commit -a -m "message"

-a 选项将添加所有已修改的跟踪文件

关于git - 无法摆脱 "Changes not staged for commit',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13630761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com