git commit --amend不提交更改

时间:2019-03-14 13:55:20

标签: git

每次我在本地进行更改并执行git commit --amend,然后执行:x保存并关闭vim或什至git commit --amend --no-edit都不会发生任何事情。没有任何本地更改被提交或上演。我完全不知道怎么可能。其他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和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

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:0)

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

相关问题