如何樱桃采摘藏在git? [英] How to cherry-pick from stash in git?
问题描述
git储存保存test cherry-pick from stash
* git cherry-pick stash @ {0} * - >这可能吗?
当我收到以下异常
时尝试以上命令
:
$ b
错误
:
〜/ Documents $ git cherry-pick stash @ {0}
错误:提交4590085c1a0d90de897633990f00a14b04405350是合并但没有-m选项被给了。
fatal:cherry-pick失败
问题在于一个存储包含两个或三个提交。当存储时,被修改的工作树被存储在一个提交中,一个提交中的索引以及(如果使用 - 包括未跟踪的
标记)任何未跟踪的文件在第三如果你使用 gitk --all
并做一个存储,你可以看到这个。
stash @ {0}
指向包含工作树的提交。
您但是,如果你愿意的话,可以从这个提交中挑选出来
git cherry-pickstash @ {0}-m 1
原因是 cherry-pick
认为存储是一个合并,因此需要 -m 1
参数是存储提交具有多堆父节点,如图所示。
我不确定你想要通过樱桃采摘来达到什么目的。一种可能的选择是从存储中创建一个分支。
git存储分支stashchanges
git commit -a -m
git checkout master
git merge stashchanges
I am wondering if cherry-picking from stash is possible.
git stash save "test cherry-pick from stash"
*git cherry-pick stash@{0}* --> Is this possible?
I am getting the following exception
when I tried above command
:
Error
:
~/Documents$ git cherry-pick stash@{0}
error: Commit 4590085c1a0d90de897633990f00a14b04405350 is a merge but no -m option was given.
fatal: cherry-pick failed
The problem is that a stash consists of two or three commits. When stashing, the modified working tree is stored in one commit, the index in one commit, and (if using the --include-untracked
flag) any untracked files in a third commit.
You can see this if you use gitk --all
and do a stash.
stash@{0}
points to the commit that contains the working tree.
You can however cherry-pick from that commit if you do
git cherry-pick "stash@{0}" -m 1
The reason that cherry-pick
thinks that the stash is a merge, and thus needs the -m 1
parameter is that the stash commit has multpile parents, as you can see in the graph.
I am not sure exactly what you want to achieve by cherry-picking. A possible alternative is to create a branch from the stash. Commit changes there and merge them to your current branch.
git stash branch stashchanges
git commit -a -m "changes that were stashed"
git checkout master
git merge stashchanges
这篇关于如何樱桃采摘藏在git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!