gpt4 book ai didi

git - 从不同的存储库中 pull 提交

转载 作者:太空狗 更新时间:2023-10-29 13:55:37 24 4
gpt4 key购买 nike

我已经克隆了一个项目供我使用,但一位 friend 对原始项目进行了更改。我想将该提交中的更改提取到我的项目中。

使用

git fetch https://github.com/cvandermeer/wisemonkeys.git f70bcfd75a498ed9159b6e5313e306166fc3df62

抛出以下错误:

error: no such remote ref f70bcfd75a498ed9159b6e5313e306166fc3df62

git remote -v 给我以下内容,

origin  https://github.com/alucardu/appsynth.git (fetch)
origin https://github.com/alucardu/appsynth.git (push)

是否无法从不同的项目中提取提交?

最佳答案

(为方便起见,以下称您的 friend 为“爱丽丝”。)

您获取引用(分支或标签),而不是提交

I would like to pull the changes from that commit into my project.

Is it not possible to pull a commit from a different project?

严格来说,您不获取提交;你获取引用(分支或标签)。如果您对 Alice 的存储库中存在但您的存储库中不存在的特定提交感兴趣,则需要获取一个引用,其祖先包含来自 Alice 的存储库中的相关提交。

使用有效的 git fetch句法

Using [...] throws the following error [...]

你正在使用的命令,

git fetch <remote-url> <commit>

不是有效的 git fetch语法,因此你得到的错误。您要使用的语法是

git fetch <repository> 

哪里<repository>是一个远程的,即你的本地仓库知道 Alice 的仓库的昵称。您可能想要更具体并添加 refspec在此命令的末尾。

编辑:正如 torek 在 his comment 中指出的那样,您还可以使用裸 URL,而无需在本地存储库中配置远程,但这可能不是您想要在此处执行的操作。

首先将 Alice 的存储库添加为远程

git remote -v gives me the following [...]

git remote -v 的输出表示您还没有将 Alice 的存储库添加为本地存储库的远程。在从中获取之前,您需要这样做:

git remote add alice https://github.com/cvandermeer/wisemonkeys.git

获取并了解有关感兴趣的提交的更多信息

然后运行

git fetch alice

从 Alice 的存储库中获取您还没有的所有内容。然后你可以运行

git name-rev f70bcfd75a498ed9159b6e5313e306166fc3df62  

识别可从中访问提交的引用,以及

git show f70bcfd75a498ed9159b6e5313e306166fc3df62

打印有关提交的信息并决定如何处理它(精心挑选它,将它所在的分支 merge 到您的本地分支之一,等等)。

其他资源

关于git - 从不同的存储库中 pull 提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28262554/

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