git提交--修改不提交更改

git提交--修改不提交更改,git,Git,任何时候我在本地进行更改并执行git commit--amend,然后执行:x保存并关闭vim,甚至只执行git commit--amend--不进行编辑都不会发生任何事情。未提交或暂存任何本地更改。我完全搞不懂这怎么可能。其他rebaseing活动在编辑器中正常工作 这是一份完整的工作报告: amendwtf|master ⇒ ls file amendwtf|master ⇒ git status On branch master nothing to commit, working tre

任何时候我在本地进行更改并执行
git commit--amend
,然后执行
:x
保存并关闭vim,甚至只执行
git commit--amend--不进行编辑
都不会发生任何事情。未提交或暂存任何本地更改。我完全搞不懂这怎么可能。其他
rebase
ing活动在编辑器中正常工作

这是一份完整的工作报告:

amendwtf|master ⇒ ls
file
amendwtf|master ⇒ git status
On branch master
nothing to commit, working tree clean
amendwtf|master ⇒ echo 'a change appears' > file
amendwtf|master⚡ ⇒ git status
On branch master
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:   file

no changes added to commit (use "git add" and/or "git commit -a")
amendwtf|master⚡ ⇒ git commit --amend --no-edit
[master 3b577b8] initial commit
 Date: Thu Mar 14 09:49:08 2019 -0400
 1 file changed, 1 insertion(+)
 create mode 100644 file
amendwtf|master⚡ ⇒ git status
On branch master
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:   file

no changes added to commit (use "git add" and/or "git commit -a")
amendwtf|master⚡ ⇒

您没有为提交准备任何内容(使用
git add file
),并且您没有在提交命令行上放置任何文件名,因此
git commit--amend
将只编辑提交消息、提交日期/时间,以及可能在命令行上列出的其他内容(在您的情况下没有)。如果要将更改提交到文件,请先添加该文件,或在提交命令行中指定它。

我忘记了一个
-a
。我想要的是
git commit-a--amend--no edit

我建议不要使用
-a
。相反,首先运行
git add-u
,这就是
git commit-a
所做的,但是现在您可以运行
git status
,并确保输出反映了您在下一次
git commit
期间想要发生的事情,无论是使用
--amend
还是不使用。(当然,一旦你熟悉了
git add-u
,并且确信它会做你想做的事情,那么
git commit-a
就可以了。不过我自己仍然使用
-u
amendwtf|master⚡ ⇒ git --version
git version 2.21.0
amendwtf|master⚡ ⇒ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)
Included patches: 1-503, 505-680, 682-1283