git - git commit --amend 不提交更改
问题描述
任何时候我在本地进行更改并执行任何一项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
解决方案
我忘记了一个-a
. 我想要的是git commit -a --amend --no-edit
。
推荐阅读
- json - AWS AppSync:如何通过 DynamoDB 返回有效的 JSON
- mysql - Mysql ERROR 1071 (42000): 指定的key太长;最大密钥长度为 3072 字节
- java - 如何控制加密字符串的长度(密码学 - 加密)
- vuejs2 - 在类星体框架中存储全局对象的位置
- java - MongoDB使用Java使用正则表达式查询字段中的值
- mysql - MySQL 复杂条件选择查询
- rest - 关于 HTTP 动词的困惑
- sql - 如何从存储在两个不同表中的数据中返回具有自定义结构的内容
- ansible - 将单个变量传递给 Ansible 角色中定义的变量列表
- git - 为什么 git diff --name-only 不显示任何修改过的文件?