为什么git无法通过路径进行硬/软重置? [英] Why git can't do hard/soft resets by path?

查看:1124
本文介绍了为什么git无法通过路径进行硬/软重置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ git reset - < file_path> 可以通过路径重置。 然而,会报告如下的错误:

 无法通过路径进行硬重置|软重置。 


解决方案

因为没有意义(其他命令已经提供了该功能),它减少了意外执行错误事件的可能性。

一个路径的硬重置只需要完成 git checkout HEAD - < path> (检出文件的现有版本)。

路径的软重置不会使感觉。

路径的混合重置是 git reset - < path> p>

$ git reset -- <file_path> can reset by path.

However, $ git reset (--hard|--soft) <file_path> will report an error like below:

Cannot do hard|soft reset with paths.

解决方案

Because there's no point (other commands provide that functionality already), and it reduces the potential for doing the wrong thing by accident.

A "hard reset" for a path is just done with git checkout HEAD -- <path> (checking out the existing version of the file).

A soft reset for a path doesn't make sense.

A mixed reset for a path is what git reset -- <path> does.

这篇关于为什么git无法通过路径进行硬/软重置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆