例如,我从干净提交开始,对不同的文件进行一些更改,然后只从一个文件中删除所做的更改。我该怎么做呢?
我试着做:
git stash -p train.py
但我有个错误:
fatal: subcommand wasn't specified; 'push' can't be assumed due to unexpected token 'train.py'
发布于 2021-11-18 09:45:58
之所以会出现此错误,是因为git stash push
( git stash -p
是其别名)不允许自定义参数,以避免意外存储。
来自git stash push
的文档
为了快速拍摄快照,您可以省略“推送”。在此模式下,不允许非选项参数阻止拼写错误的子命令生成不需要的存储项。这方面的两个例外是
stash -p
,它充当stash push -p
和路径规范元素的别名,允许在双连字符--
之后消除歧义。
在您的示例中,train.py
是一个https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec,因此必须添加如下所示的--
,从而将其与已识别的选项分开:
git stash -p -- train.py
或者,您可以拼写出整个命令,在这种情况下,您不必用双破折号分隔路径:
git stash push -p train.py
发布于 2021-11-18 09:17:30
您应该:
git rebase HEAD~1
# Change, by the editor just opened, the word pick into edit, save and exit
# Edit you file
git commit
https://stackoverflow.com/questions/70017175
复制相似问题