git rebase 致命:需要一个修订版
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4798080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git rebase fatal: Needed a single revision
提问by jrlmx2
I have a branch of a public repository and I am trying to update my branch with the current commits from the original repository:
我有一个公共存储库的分支,我正在尝试使用原始存储库中的当前提交更新我的分支:
$ git fetch <remote>
remote: Counting objects: 24, done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 20 (delta 12), reused 0 (delta 0)
Unpacking objects: 100% (20/20), done.
From git://github.com/path_to/repo
9b70165..22127d0 master -> $/master
$ git rebase <remote>
fatal: Needed a single revision
invalid upstream <remote>
The <remote>
is in place of my remote name and is not actually my remote name. The documentation on this error seems to be a bit loose.
该<remote>
在的地方我的远程名的,实际上并不是我的远程名称。关于此错误的文档似乎有点松散。
采纳答案by CB Bailey
You need to provide the name of a branch (or other commit identifier), not the name of a remote to git rebase
.
您需要提供分支的名称(或其他提交标识符),而不是远程名称git rebase
。
E.g.:
例如:
git rebase origin/master
not:
不是:
git rebase origin
Note, although origin
should resolve to the the ref origin/HEAD
when used as an argument where a commit reference is required, it seems that not every repository gains such a reference so it may not (and in your case doesn't) work. It pays to be explicit.
请注意,虽然在用作需要提交引用的参数时origin
应该解析为 ref origin/HEAD
,但似乎并非每个存储库都获得这样的引用,因此它可能无法(在您的情况下不起作用)。明确是值得的。
回答by ChrisJF
Check that you spelled the branch name correctly. I was rebasing a story branch (i.e. branch_name
) and forgot the story part. (i.e. story/branch_name
) and then git spit this error at me which didn't make much sense in this context.
检查您是否正确拼写了分支名称。我正在重新设置一个故事分支(即branch_name
)并忘记了故事部分。(即story/branch_name
)然后 git 向我吐出这个错误,这在这种情况下没有多大意义。
回答by Mario Olivio Flores
I ran into this and realized I didn't fetch the upstream before trying to rebase. All I needed was to git fetch upstream
我遇到了这个问题并意识到在尝试变基之前我没有获取上游。我所需要的只是git fetch upstream
回答by Maitreya
The issue is that you branched off a branch off of.... where you are trying to rebase to. You can't rebase to a branch that does not contain the commit your current branch was originally created on.
问题是你分支了一个分支......你试图重新定位到哪里。您不能重新定位到不包含您的当前分支最初创建的提交的分支。
I got this when I first rebased a local branch X to a pushed one Y, then tried to rebase a branch (first created on X) to the pushed one Y.
当我第一次将本地分支 X 重新定位到推送的 Y 时,我得到了这个,然后尝试将一个分支(首先在 X 上创建)重新定位到推送的 Y。
Solved for me by rebasing to X.
通过重新定位到 X 为我解决了问题。
I have no problem rebasing to remote branches (potentially not even checked out), provided my current branch stems from an ancestor of that branch.
如果我当前的分支来自该分支的祖先,我可以重新定位到远程分支(可能甚至没有签出)。
回答by Jani
For remote origin
:
对于远程origin
:
$ echo "ref: refs/remotes/origin/master" > .git/refs/remotes/origin/HEAD
回答by Deepesh Panjabi
git submodule deinit --all -f
worked for me.
git submodule deinit --all -f
对我来说有效。