gpt4 book ai didi

git - 是否可以从另一个 git 存储库中挑选一个提交?

转载 作者:IT王子 更新时间:2023-10-29 01:09:01 25 4
gpt4 key购买 nike

我正在使用一个 git 存储库,它需要来自另一个对第一个一无所知的 git 存储库的提交。

通常我会在 reflog 中使用 HEAD@{x} 进行 cherry-pick,但是因为这个 .git 不知道这个 reflog 条目(不同的物理目录) ,我该如何挑选这个,或者我可以吗?

我正在使用 git-svn。我的第一个分支正在使用 Subversion 存储库的 trunkgit-svn,下一个分支在 Subversion 分支上使用 git-svn .

最佳答案

给出的答案是使用格式补丁,但由于问题是如何从另一个文件夹中挑选,这里有一段代码可以做到这一点:

$ git --git-dir=../<some_other_repo>/.git \
format-patch -k -1 --stdout <commit SHA> | \
git am -3 -k

马从的解释comment Aug 28 '14

git format-patch command creates a patch from some_other_repo's commitspecified by its SHA (-1 for one single commit alone). This patch ispiped to git am, which applies the patch locally (-3 means trying thethree-way merge if the patch fails to apply cleanly).

关于git - 是否可以从另一个 git 存储库中挑选一个提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5120038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com