首页 > 解决方案 > git commit --amend 不提交更改

问题描述

任何时候我在本地进行更改并执行任何一项git commit --amend,然后:x保存并关闭 vim 或什至git commit --amend --no-edit什么都没有发生。没有提交或暂存任何本地更改。我完全不知道这怎么可能。其他rebaseing 活动在编辑器中正常工作。

这是一个完整的工作再现:

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 和 vim 版本:

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

标签: git

解决方案


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


推荐阅读