"git stash create x" - 它在哪里? [英] "git stash create x" - Where is it?

查看:137
本文介绍了"git stash create x" - 它在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用git stash create whatever创建提交,则会得到该提交的哈希,但是我找不到使用git reflog的提交哈希.

If I create a commit with git stash create whatever I get a hash of the commit back, but I can't find that commit hash with git reflog.

git log stash也不起作用,git stash list也不起作用.

git log stash doesn't work either, not does git stash list.

如何列出使用git stash create 创建的提交?

How can I list the commits I create using git stash create?

推荐答案

如果使用

If you use the script in this answer, you can then do git stash list.

#!/bin/sh
#
# git-stash-push
# Push working tree onto the stash without modifying working tree.
# First argument (optional) is the stash message.
if [ -n "$1" ]; then
        git update-ref -m "$1" refs/stash "$(git stash create \"$1\")"
else
        HASH=`git stash create`
        MESSAGE=`git --no-pager log -1 --pretty="tformat:%-s" "$HASH"`
        git update-ref -m "$MESSAGE" refs/stash "$HASH"
fi

然后,您实际上可能希望在某个时候重新获得该提交.为此,您可以使用git stash list列出存储区,这会给您类似的信息(请记住,这些存储区可能是愚蠢的提交消息):

Then you may actually want to get that commit back at some point. To do this, you can list the stashes using git stash list which gives you something like this (remember, these can be dumb commit messages):

stash@{0}: WTF? Nothing is working
stash@{1}: it's all working perfectlY!
stash@{2}: blah2

然后您可以通过运行以下命令来还原blah2:

Then you can restore, say, blah2 by running:

 git stash pop stash@{2}

或@Eliot指出,您可以使用它来不破坏您的藏匿处:

or as @Eliot points out, you can use this to not destroy your stash:

 git stash apply stash@{2}

这篇关于"git stash create x" - 它在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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