本文介绍了git stash drop最旧的存储(例如最旧的5个存储)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在一个语句中删除最旧的存储区(例如最旧的5个存储区),而不是执行以下操作:
How do I drop oldest stashes (say oldest 5 stashes) in one statement instead of doing something like this:
git stash drop stash@{3} git stash drop stash@{4} git stash drop stash@{5} git stash drop stash@{6} git stash drop stash@{7} 推荐答案感谢匿名用户的编辑,正确的命令应如下所示:
Thanks to an anonymous user's edit, the correct command would look like this:
git stash list | cut -f 1 -d : | tail -5 | sort -r | xargs -n 1 git stash drop这是他/她的解释:
- git隐藏列表:列出所有隐藏列表
- cut -f 1 -d :仅选择第一列(存储标识符,例如stash @ {29})
- tail -5 :仅保留最后五行
- sort -r :反转行的顺序以首先删除最旧的存储区(否则,其余的存储区在每次删除后都会获得新名称)
- xargs -n 1 git stash drop :对于管道中传输的每一行,执行git stash drop,因为 git stash drop [可能]仅支持一个stash a.时间.
- git stash list: List all your stashes
- cut -f 1 -d: Select only the first column (stash identifier, for example stash@{29})
- tail -5: Keep only the last five lines
- sort -r: Invert the order of the lines to drop the oldest stash first (otherwise remaining stashes get new names after each removal)
- xargs -n 1 git stash drop: For each line transmitted in the pipe, execute git stash drop, since git stash drop [may] support only one stash a time.
所有对神秘陌生人的敬意.
All kudos to the mysterious stranger.
更多推荐
git stash drop最旧的存储(例如最旧的5个存储)
发布评论