Git还原在简单文件中不起作用
我有一个文本文件,然后进行了Git还原在简单文件中不起作用,git,version-control,Git,Version Control,我有一个文本文件,然后进行了4次提交添加了一些内容 显示这个 b8855f5 HEAD@{0}: commit: sample file 7, 8 76a0a1d HEAD@{1}: commit (amend): sample file 5, 6 c1e92ac HEAD@{2}: commit: sample file 35,6 a96273f HEAD@{3}: commit: sample file 3,4 c296a17 HEAD@{4}: commit: sample file ad
4次提交
添加了一些内容
显示这个
b8855f5 HEAD@{0}: commit: sample file 7, 8
76a0a1d HEAD@{1}: commit (amend): sample file 5, 6
c1e92ac HEAD@{2}: commit: sample file 35,6
a96273f HEAD@{3}: commit: sample file 3,4
c296a17 HEAD@{4}: commit: sample file added
我想做的是恢复提交a96273f
我试过这个,得到了这个
git revert -n a96273
error: could not revert a96273f... sample file 3,4
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
git还原-n a96273
错误:无法还原a96273f。。。示例文件3,4
提示:解决冲突后,标记更正的路径
提示:使用“git add”或“git rm”
提示:并使用“git commit”提交结果
像git apply
和git merge
,git revert
有时需要用户帮助解决冲突
例如,假设在commita96273
中添加了打油诗的第三行和第四行:
A mathematician named Klein
Thought the Moebius band was divine
Said he, "If you glue
The edges of two
You'll get a weird bottle like mine!"
然后,假设在随后的提交中,您将“Moebius”的拼写更改为使用umlaut“Möbius”
如果您随后尝试
git还原a96273
,git会发现更改是添加了它可以找到的两个缩进行,因此这没有问题,但第一个缩进行之前的行显示为“Moebius”。现在那里的线不匹配。Git无法确定删除两个缩进行是否正确,因此它会因冲突而停止,并要求您编辑文件,选择最终正确的格式,然后执行Git add
和Git commit
以完成还原操作。类似于Git apply
和Git merge
,git revert
有时需要用户的帮助来解决冲突
例如,假设在commita96273
中添加了打油诗的第三行和第四行:
A mathematician named Klein
Thought the Moebius band was divine
Said he, "If you glue
The edges of two
You'll get a weird bottle like mine!"
然后,假设在随后的提交中,您将“Moebius”的拼写更改为使用umlaut“Möbius”
如果您随后尝试
git还原a96273
,git会发现更改是添加了它可以找到的两个缩进行,因此这没有问题,但第一个缩进行之前的行显示为“Moebius”。现在那里的线不匹配。Git无法确定删除两个缩进行是否正确,因此它会因冲突而停止,并要求您编辑文件,选择最终正确的格式,然后执行一个Git add
和Git commit
来完成还原操作。我想您要做的是将txt文件重置为a96273,因此,您要查找的命令是git reset
而不是git revert
Try命令:git reset--hard a96273
,此命令将放弃a96273之后的所有更改,因此非常危险,小心
如果您只想回滚以提交a96273,而不放弃更改,请使用git reset--soft a96273
您可以查看git reset的手册页我认为您要做的是将txt文件重置为a96273,因此您要查找的命令是
git reset
而不是git revert
Try命令:git reset--hard a96273
,此命令将放弃a96273之后的所有更改,因此非常危险,小心
如果您只想回滚以提交a96273,而不放弃更改,请使用git reset--soft a96273
您可以查看git reset手册页是否删除了从a96273f到当前版本的任何提交文件?否,只有一个文件,我只是为了测试而做的。这是一个简单的文本文件,为TETSING添加了数字。您是否删除了从a96273f到当前版本的任何提交文件?不,只有一个文件,我只是为了测试而做的。它是一个简单的文本文件,为tetsing添加了数字