我刚刚在master
上有一个commit
,而没有merge
它进入remote
,然后我想删除我的commit
并保留我的更改文件,更改我的branch
然后commit
它们。
现在我已经使用了$git重置--soft head~1
,但是我遇到了这个错误:
fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
head~1
是指向“当前提交的父级”的方法
在您的情况下:(仅)主控上的提交没有父级。。。
如果您打算在另一个分支上提交此命令,只需创建另一个分支:
git checkout -b my/branch
# the above is a shortcut to :
git branch my/branch # create a new branch `my/branch` on the current commit
git checkout my/branch # switch to this branch
对于历史记录中的一个提交,“从master
中删除提交”与“删除master
”相同。
这样做没有什么坏处(您可以稍后重新创建它):git branch-d master
,
但是您也可以使用本地的master
分支。