[英]Pull a commit from a different repository
I've cloned a project for me to work on, but a friend made a change on the original project. 我克隆了一个项目让我继续工作,但是一位朋友对原始项目进行了修改。 I would like to pull the changes from that commit into my project.
我想将该提交的更改提取到我的项目中。
Using 运用
git fetch https://github.com/cvandermeer/wisemonkeys.git f70bcfd75a498ed9159b6e5313e306166fc3df62
throws the following error: 抛出以下错误:
error: no such remote ref f70bcfd75a498ed9159b6e5313e306166fc3df62
错误:没有这样的远程参考f70bcfd75a498ed9159b6e5313e306166fc3df62
git remote -v
gives me the following, git remote -v
给了我以下内容,
origin https://github.com/alucardu/appsynth.git (fetch)
origin https://github.com/alucardu/appsynth.git (push)
Is it not possible to pull a commit from a different project? 是否无法从其他项目中提取提交?
(For convenience, let's call your friend "Alice" in the following.) (为方便起见,让我们在下面给你的朋友“爱丽丝”打电话。)
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?
是否无法从其他项目中提取提交?
Strictly speaking, you don't fetch commits; 严格来说,你不提取提交; you fetch references (branches or tags).
你获取引用 (分支或标签)。 If you're interested in a particular commit that exists in Alice's repo but not in yours, you'll need to fetch a reference whose ancestry contains the commit in question from Alice's repo.
如果你对Alice的repo中存在的特定提交感兴趣而不是你的存在,那么你需要从Alice的repo中获取其祖先包含有问题的提交的引用。
git fetch
syntax git fetch
语法 Using [...] throws the following error [...]
使用[...]会引发以下错误[...]
The command you're using, 你正在使用的命令,
git fetch <remote-url> <commit>
is not a valid git fetch
syntax, hence the error you're getting. 不是一个有效的
git fetch
语法,因此你得到的错误。 The syntax you want to use is 您要使用的语法是
git fetch <repository>
where <repository>
is a remote, ie a nickname under which your local repo knows Alice's repo. 其中
<repository>
是一个遥控器,即你的本地<repository>
知道Alice的回购的昵称。 You may want to be more specific and also add a refspec at the end of this command. 您可能希望更具体,并在此命令的末尾添加refspec 。
Edit : As pointed out by torek in his comment , you can also use a naked URL, without configuring the remote in your local repository, but that's probably not what you want to do, here. 编辑 :正如torek在他的评论中指出的那样,您也可以使用裸URL,而无需在本地存储库中配置远程,但这可能不是您想要做的,这里。
git remote -v
gives me the following [...]git remote -v
给了我以下[...]
The output of git remote -v
indicates that you haven't added Alice's repo as a remote of your local repository yet. git remote -v
的输出表明您尚未将Alice的repo添加为本地存储库的远程 。 You need to to that before you can fetch from it: 你需要先从中获取它:
git remote add alice https://github.com/cvandermeer/wisemonkeys.git
Then run 然后跑
git fetch alice
to fetch everything you don't already have from Alice's repo. 从Alice的回购中获取你还没有的所有东西。 You can then run
然后你就可以跑了
git name-rev f70bcfd75a498ed9159b6e5313e306166fc3df62
to identify a reference from which the commit is accessible, and 识别可以访问提交的引用,以及
git show f70bcfd75a498ed9159b6e5313e306166fc3df62
to print information about the commit and decide what to do with it (cherry-pick it, merge the branch it's on into one of your local branches, etc.). 打印有关提交的信息并决定如何处理它(樱桃挑选它,将它的分支合并到你的一个本地分支机构等)。
git fetch
and git remote
man pages git fetch
和git remote
手册页 I would suggest the following sequence of actions: 我建议采取以下一系列措施:
1) Connect the other repository as a remote repository, with git remote. 1)使用git remote将另一个存储库作为远程存储库连接。
2) Pull it. 2)拉它。
3) Use git cherry-pick
to pluck the commit from the other repository, into yours. 3)使用
git cherry-pick
从其他存储库中提取您的提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.