什么会导致提交未暂存的文件?
What can cause not staged files to be commited?
我编辑了两个文件。我想提交其中一个文件中的部分更改,因此我已将这些更改添加到暂存区。事情看起来正确:
$ git status
On branch feature/foo
Your branch is up to date with 'origin/feature/foo'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: src/App/Foo.php
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: docker-compose.yml
modified: src/App/Foo.php
但是,当我最终提交时,另一个文件也包含在提交中!
$ git commit -m Spelling
[feature/foo ad0c758a6] Spelling
2 files changed, 5 insertions(+), 3 deletions(-)
$ git status
On branch feature/foo
Your branch is ahead of 'origin/feature/foo' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/App/Foo.php
no changes added to commit (use "git add" and/or "git commit -a")
我做错了什么?
我在 Windows 10 Pro 上的 WSL2 中的 Ubuntu 20.04 中使用 git 2.25.1。文件存储在 Ubuntu 文件系统中,我 运行 命令在 Ubuntu bash.
对 git commit
进行自动操作的一种方法是通过挂钩。
检查你的 repo 上是否有任何活动的挂钩:
ls .git/hooks
看看那里是否有 pre-commit
脚本。
我编辑了两个文件。我想提交其中一个文件中的部分更改,因此我已将这些更改添加到暂存区。事情看起来正确:
$ git status
On branch feature/foo
Your branch is up to date with 'origin/feature/foo'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: src/App/Foo.php
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: docker-compose.yml
modified: src/App/Foo.php
但是,当我最终提交时,另一个文件也包含在提交中!
$ git commit -m Spelling
[feature/foo ad0c758a6] Spelling
2 files changed, 5 insertions(+), 3 deletions(-)
$ git status
On branch feature/foo
Your branch is ahead of 'origin/feature/foo' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/App/Foo.php
no changes added to commit (use "git add" and/or "git commit -a")
我做错了什么?
我在 Windows 10 Pro 上的 WSL2 中的 Ubuntu 20.04 中使用 git 2.25.1。文件存储在 Ubuntu 文件系统中,我 运行 命令在 Ubuntu bash.
对 git commit
进行自动操作的一种方法是通过挂钩。
检查你的 repo 上是否有任何活动的挂钩:
ls .git/hooks
看看那里是否有 pre-commit
脚本。