从另一个git仓库挑选一个提交?

我正在使用一个git仓库,它需要来自另一个git仓库的提交,它不知道第一个仓库。

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

我正在使用git-svn 。 我的第一个分支是使用Subversion repo的trunkgit-svn ,下一个分支是在Subversion分支上使用git-svn


您需要将其他存储库添加为远程,然后获取其更改。 从那里你会看到提交,你可以选择它。

像那样:

git remote add other https://example.link/repository.git
git fetch other

现在你拥有了所有的信息来简单地做git cherry-pick

有关使用遥控器的更多信息,请访问:https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes


正如给出的答案是使用format-patch,但是由于问题是如何从另一个文件夹中挑选,下面是一段代码:

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

(来自@cong ma的解释)

git format-patch命令从它的SHA指定的some_other_repo提交中创建一个补丁( -1代表一个提交)。 这个补丁管道到git am ,它在本地应用补丁( -3表示尝试三路合并,如果补丁无法清晰地应用)。 希望解释。


以下是远程获取合并的示例。

cd /home/you/projectA
git remote add projectB /home/you/projectB
git fetch projectB

那么你有一个选择:

git merge projectB/master

要么:

git cherry-pick <first_commit>..<last_commit>
链接地址: http://www.djcxy.com/p/68741.html

上一篇: pick a commit from another git repository?

下一篇: Visualizing branch topology in git