我已经用了很长一段时间了。我最近发现了git stash apply命令。当我尝试它时,它似乎和git stash pop一样有效。
gitstashpop和gitstashapply之间有什么区别?
我已经用了很长一段时间了。我最近发现了git stash apply命令。当我尝试它时,它似乎和git stash pop一样有效。
gitstashpop和gitstashapply之间有什么区别?
当前回答
假设不会抛出错误,并且您希望处理可用存储列表中的顶部存储项:
gitstashpop=gitstashapply+gitstashdrop
其他回答
Git Stash Pop与应用工作
如果你想将你的顶级隐藏更改应用于当前的非暂存更改并删除该隐藏,那么你应该使用git隐藏pop。
# apply the top stashed changes and delete it from git stash area.
git stash pop
但是,如果您想在不删除当前未暂存的更改的情况下,将顶部隐藏的更改应用于当前未暂存更改,那么您应该使用git stash apply。
注意:您可以将这种情况与Stack类pop()和peek()方法联系起来,其中pop以递减的方式改变top(top=top 1),但peech()只能获得top元素。
快速回答:
git stash pop->从隐藏列表中删除
git存储应用->将其保存在存储列表中
git stash pop在应用后丢弃(默认情况下是最上面的)存储,而git stashapply将其保留在存储列表中,以便以后重用(或者您可以将其丢弃)。
除非在git stash pop之后发生冲突,否则会发生这种情况,在这种情况下,它不会删除该stash,使其行为与git stashapply完全相同。
另一种方法是:gitstashpop是gitstashapply&&gitstashdrop。
假设不会抛出错误,并且您希望处理可用存储列表中的顶部存储项:
gitstashpop=gitstashapply+gitstashdrop
你可以用同样的方式思考,这就是我学习的方式:
gitstashpop->ctrl+x,ctrl+v(剪切粘贴)
git stash apply->ctrl+c,ctrl+v(复制并粘贴)