如何丢弃 SourceTree 中未提交的更改? [英] How to discard uncommitted changes in SourceTree?

查看:259
本文介绍了如何丢弃 SourceTree 中未提交的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Git 环境的新手,我在 Mac 上使用 BitBucket 和 SourceTree.我现在要做的就是放弃自上次提交以来的更改.我该怎么做?我还没有发现像放弃更改"这样的东西,而且直接从最后一次提交中提取似乎不起作用.使用 GUI 或命令行完成的解决方案会很好.

I'm new to the Git environment, and I'm using BitBucket with SourceTree on Mac. All I want to do now is to discard the changes since last commit. How should I do this? I haven't found anything like "discard changes", and directly pulling from the last commit doesn't seem to work. Solutions done with either the GUI or command line will be good.

推荐答案

我喜欢用

git stash

这会将所有未提交的更改存储在 stash 中.如果您以后想放弃这些更改,只需 git stash drop(或 git stash pop 以恢复它们).

This stores all uncommitted changes in the stash. If you want to discard these changes later just git stash drop (or git stash pop to restore them).

虽然这在技术上不是放弃更改的正确"方式(正如其他答案和评论所指出的那样).

Though this is technically not the "proper" way to discard changes (as other answers and comments have pointed out).

SourceTree:在顶部栏上单击图标Stash",输入其名称并创建.然后在左侧垂直菜单中,您可以显示"所有 Stash 并在右键菜单中删除.ST 中可能没有其他方法可以一次性丢弃所有文件.

SourceTree: On the top bar click on icon 'Stash', type its name and create. Then in left vertical menu you can "show" all Stash and delete in right-click menu. There is probably no other way in ST to discard all files at once.

这篇关于如何丢弃 SourceTree 中未提交的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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