场景

比如软件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
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐