git commit --amend 存在版本回退动作
使用到git commit –amend
经过以下命令:
git pull
git add .
git commit --amend
在暂存区中,存在上一次提交的修改代码,于我所期望不同
所以查询了解git commit –amend的具体细节
git
git是一个免费开源的分布式版本控制系统,被设计用于快捷高效地处理从小到大的项目。[1]
能够应用于代码仓管理,例如github、gitlib、gitea等等。
git commit
git commit——记录对于存储库的更改
创建一个新的提交,其中包含对当前内容的索引和给予描述更改内容的日志消息。[2]
git commit –amend
通过创建一个新的提交来替换当前分支的tip(感觉可以翻译成提交对象,commit object)。
并且当未指定其他tip时,使用原始提交的备注信息作为起点。
可以粗暴的等效为:
git reset --soft HEAD</sup>
... do something else to come up with the right tree ...
git commit -c ORIG_HEAD
但是通常被使用去修正一个合入提交。[2]
由此,知道使用git commit –amend确实存在版本回退的现象,
且了解其正确使用方法应该是:
git commit -m xx
git add forgottenFiles
git commit --amend
其作用也并不是正常提交,而是去修正之前合入提交信息。
参考
[1] https://git-scm.com/
[2] https://git-scm.com/docs/git-commit