当我在git
中生成一个stash时,会有一个“父级”(即我stash我的更改之前的最后一次提交)。
当我使用git stash
来存储我的更改时,会将指向该父级提交的ID添加到描述我的stash的消息中。调用git stash list
可以显示:
stash@{0}: WIP on master: c09a3fc second commit
stash@{1}: WIP on master: 063b893 first commit
stash@{2}: WIP on master: 063b893 first commit
但是,当我运行git stash save "我的自定义信息"
时,父提交的ID不会被添加到git stash list
中:
stash@{0}: On master: My own message
stash@{1}: WIP on master: c09a3fc second commit
stash@{2}: WIP on master: 063b893 first commit
stash@{3}: WIP on master: 063b893 first commit
有没有办法在存储列表中显示父提交的ID?
我尝试了以下命令:
git stash list --oneline --parents
,但它只返回:1b5dfb1 4efd3e0 refs/stash@{0}: On master: My own message
4efd3e0 1e9b384 refs/stash@{1}: WIP on master: c09a3fc second commit
1e9b384 51eb834 refs/stash@{2}: WIP on master: 063b893 first commit
51eb834 refs/stash@{3}: WIP on master: 063b893 first commit
但这里显示的ID是错误的。我期望的是(第一行是父提交的ID,在这个例子中,每两个提交的组的父提交是相同的):
c09a3fc 1b5dfb1 refs/stash@{0}: On master: My own message
c09a3fc 4efd3e0 refs/stash@{1}: WIP on master: c09a3fc second commit
063b893 1e9b384 refs/stash@{2}: WIP on master: 063b893 first commit
063b893 51eb834 refs/stash@{3}: WIP on master: 063b893 first commit
git show stash@{0}^
命令,因为stash@{0}
是一个有效的引用名称。您可以编写一个小脚本来获取所需的输出 - 但这是读者的练习,所以这只是一条注释 :-) - Jan Fabrygit show stash@{0}^
是我在这里提出的问题的答案吗?https://stackoverflow.com/questions/62840077/how-to-recover-from-git-added-by-us-conflict-after-applying-stash-after-renami/62842712#comment111147132_62842712 - Ryan