场景
比如软件sourceTree SmartGit中会自动操作Discard,但是如何使用命令实现discard。
可以通过如下命令:
命令
比如文件 application/do/user.go
$ git status
On branch v1.0.1
Your branch is up to date with 'origin/v1.0.1'.
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
modified: application/do/user.go
$ git reset HEAD -- application/do/user.go
$ git checkout -- application/do/user.go
这样就实现了 discard 的命令了。
git reset HEAD -- path/to
git checkout -- path/to
这篇博客介绍了如何在Git中使用命令行操作来实现类似SourceTree或SmartGit的Discard功能。通过`git reset HEAD --`和`git checkout --`命令,你可以轻松丢弃对指定文件的本地修改,将文件回退到最近的提交状态。这对于撤销意外的更改或者保持代码整洁非常有用。
3783

被折叠的 条评论
为什么被折叠?



