git stash命令的使用方法是什么

git stash命令用于将当前工作目录中的所有未提交的更改(包括暂存和未暂存的更改)暂时保存起来,以便后续恢复使用。具体的使用方法如下:

将所有未暂存的更改暂时保存起来:

git stash

将所有未暂存的更改和已暂存的更改一起保存起来:

git stash -u

查看当前所有保存的stash:

git stash list

恢复最新的stash,并将其从stash列表中移除:

git stash pop

恢复指定的stash,并将其从stash列表中移除:

git stash pop stash@{n}

应用最新的stash,但不将其从stash列表中移除:

git stash apply

应用指定的stash,但不将其从stash列表中移除:

git stash apply stash@{n}

删除最新的stash:

git stash drop

删除指定的stash:

git stash drop stash@{n}

通过以上命令,可以灵活地使用git stash保存和恢复工作目录中的更改,以便在需要时快速切换工作状态。

阅读剩余
THE END