我已经克隆了一个项目供我处理,但是一个朋友对原始项目进行了更改。我想将所做的更改从提交中提取到我的项目中。
使用
git fetch github/cvandermeer/wisemonkeys.git f70bcfd75a498ed9159b6e5313e306166fc3df62投掷以下错误:
错误:没有这样的远程引用f70bcfd75a498ed9159b6e5313e306166fc3df62
git remote -v 给我以下内容,
原始github/alucardu/appsynth.git(获取)来源github/alucardu/appsynth.git(推送)是否不可能从其他项目中提取提交?
解决方案(为方便起见,在下面将您的朋友称为爱丽丝。)
您获取引用(分支或标签),而不是提交我想将所做的更改从提交中提取到我的项目中。
是否不可能从其他项目中提取提交?
严格来说,您不提取提交;您获取引用(分支或标签)。如果您对Alice的回购中存在的特定提交感兴趣,而对您的不感兴趣,则需要从Alice的回购中获取其祖先包含有问题的提交的引用。
使用有效的 git fetch 语法使用[...]会引发以下错误[... ]
您正在使用的命令,
git fetch< ; remote-url> < commit>不是有效的 git fetch 语法,因此会出现错误越来越。您要使用的语法是
git fetch< repository>其中< repository> 是远程的,即昵称根据该信息,您的本地仓库可以了解Alice的仓库。您可能需要更具体,还可以添加 refspec
编辑:如torek在他的评论,您也可以使用裸露的URL,而无需在本地存储库中配置远程服务器,但是可能不是这样您想要在这里做。
首先添加爱丽丝的回购作为远程git remote -v 给我以下内容[...]
git remote -v 表示您尚未将Alice的存储库添加为本地存储库的 remote 。您需要先执行以下操作:
git remote add alice github/cvandermeer/wisemonkeys.git获取并查找有关利益承诺的更多信息
然后运行
git取爱丽丝取回您所穿的一切还没有来自爱丽丝的仓库。然后可以运行
git name-rev f70bcfd75a498ed9159b6e5313e306166fc3df62标识可从中访问提交的引用,并且
git show f70bcfd75a498ed9159b6e5313e306166fc3df62打印有关提交的信息并决定如何处理(樱桃选择它,将其所在的分支合并到您的本地分支之一,等等)。 / p> 其他资源
- git fetch 和 git remote 手册页
- 相关问题:我该如何区分我的回购和不是起源的远程回购?
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 github/cvandermeer/wisemonkeys.git f70bcfd75a498ed9159b6e5313e306166fc3df62throws the following error:
error: no such remote ref f70bcfd75a498ed9159b6e5313e306166fc3df62
git remote -v gives me the following,
origin github/alucardu/appsynth.git (fetch) origin github/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.)
You fetch references (branches or tags), not commitsI 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.
Use a valid git fetch syntaxUsing [...] 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. The syntax you want to use is
git fetch <repository>where <repository> is a remote, i.e. a nickname under which your local repo knows Alice's repo. You may want to be more specific and also add a refspec at the end of this command.
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.
Add Alice's repo as a remote firstgit remote -v gives me the following [...]
The output of git remote -v indicates that you haven't added Alice's repo as a remote of your local repository yet. You need to to that before you can fetch from it:
git remote add alice github/cvandermeer/wisemonkeys.gitFetch and find out more about the commit of interest
Then run
git fetch aliceto fetch everything you don't already have from Alice's repo. You can then run
git name-rev f70bcfd75a498ed9159b6e5313e306166fc3df62to identify a reference from which the commit is accessible, and
git show f70bcfd75a498ed9159b6e5313e306166fc3df62to 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.).
Additional resources- git fetch and git remote man pages
- related question: How can I diff between my repo and a remote repo that's not origin?
更多推荐
从其他存储库中提取提交
发布评论