我想知道是否可以从藏匿处采摘樱桃。
git stash save "test cherry-pick from stash"
*git cherry-pick stash@{0}* --> Is this possible?
当我在exception
上方尝试时,我收到了以下command
:
Error
:
~/Documents$ git cherry-pick stash@{0}
error: Commit 4590085c1a0d90de897633990f00a14b04405350 is a merge but no -m option was given.
fatal: cherry-pick failed
答案 0 :(得分:30)
问题是存储包含两次或三次提交。当存储时,修改后的工作树存储在一次提交中,索引存储在一次提交中,并且(如果使用--include-untracked
标志)存储在第三次提交中的任何未跟踪文件。
如果您使用gitk --all
并进行存储,则可以看到此内容。
stash@{0}
指向包含工作树的提交。
如果你这样做,你可以从该提交中挑选
git cherry-pick "stash@{0}" -m 1
cherry-pick
认为存储是一个合并,因此需要-m 1
参数的原因是存储提交具有多个父级,如图所示。
我不确定你想通过樱桃采摘实现什么。一种可能的替代方法是从藏匿处创建分支。提交更改并将它们合并到当前分支。
git stash branch stashchanges
git commit -a -m "changes that were stashed"
git checkout master
git merge stashchanges
答案 1 :(得分:0)
这对我有用... git cherry-pick -nm1 stash
天啊
答案 2 :(得分:-4)
我之前没有这样做过。但是,樱桃选择的手册页说它只适用于提交。
Given one or more existing commits, apply the change each one introduces,
recording a new commit for each. This requires your working tree to be
clean (no modifications from the HEAD commit).
Stashing不是提交,也不会移动HEAD。所以,这不能做[虽然这只是猜测]