本页内容

git stash

使用 Git,您可以将当前的一组修改暂存到一个名为“stash”的虚拟暂存区中。例如,当您需要先处理优先级更高的任务,或者从另一个仓库拉取新修改时,stash 功能就非常有用。

暂存本地更改

要暂存所有本地更改,请依次进入Tools >Git >Local Repository >Stash ,然后选择“Stash ”。工作副本将重置为上次提交后的状态。

若要保存未添加到暂存区的文件的当前状态并将仓库重置为已添加到暂存区的状态,请选择Stash Unstaged Files 。

管理暂存的更改

若要显示一个对话框,其中列出所有已知的暂存更改并提供恢复、查看或删除的选项,请选择Stashes 。

创建快照

若要以特定名称保存当前工作的快照以便日后参考,请选择Take Snapshot 。工作副本不会发生改变。例如,如果您想尝试某些操作,但后来发现行不通,可以丢弃这些更改并恢复到快照的状态。

提取暂存项

若要从暂存列表中移除单个暂存状态,并将其应用到当前工作树状态之上,请依次进入“Tools ” > “Git ” > “Local Repository ” > “Stash ”,然后选择“Stash Pop ”。

另请参阅 《如何使用 Git》和《Git 入门》。

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.