git rebase fatal:需要一次修订
我有一个公共存储库的分支,我正在尝试使用原始存储库中的当前提交更新我的分支:
$ 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>
代替了我的远程名称,实际上并不是我的远程姓名。关于此错误的文档似乎有点松散。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
您需要提供分支的名称(或其他提交标识符),而不是
git rebase
的远程名称。例如:
不是:
注意,虽然
origin
在用作需要提交引用的参数时应该解析为 reforigin/HEAD
,但似乎并不是每个存储库都会获得这样的参考,所以它可能不起作用(在你的情况下不起作用)。明确是值得的。You need to provide the name of a branch (or other commit identifier), not the name of a remote to
git rebase
.E.g.:
not:
Note, although
origin
should resolve to the the reforigin/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.检查您分支名称的拼写是否正确。我正在重新调整故事分支(即
branch_name
)并忘记了故事部分。 (即story/branch_name
)然后 git 向我吐出这个错误,这在这种情况下没有多大意义。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.我遇到了
致命:需要一次修订
并意识到我在尝试变基之前没有获取上游。我所需要的只是首先git fetch uploaded
。I ran into
fatal: Needed a single revision
and realized I didn't fetch the upstream before trying to rebase. All I needed was togit fetch upstream
first.问题是您从...分支出一个分支,您试图重新定位到该分支。您无法变基到不包含最初创建当前分支的提交的分支。
当我第一次将本地分支 X 重新基化为推送的 Y,然后尝试将分支(首先在 X 上创建)重新基化为推送的 Y 时,我得到了这个问题。
通过重新基址到 X 解决了我的问题。
重新基址到远程没有问题分支(可能甚至没有签出),前提是我当前的分支源于该分支的祖先。
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.
Solved for me by rebasing to 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.
当您的存储库没有为远程设置默认分支时,就会出现此错误。您可以使用 git remote set-head 命令修改默认分支,从而能够使用远程名称而不是该远程中的指定分支。
查询远程(在本例中为
origin
)的HEAD
(通常为master
),并将其设置为默认分支:如果您想要要在本地使用不同的默认远程分支,您可以指定该分支:
设置默认分支后,您可以在 git rebase和任何其他命令中仅使用远程名称,而不是显式使用
<远程>/<分支>
。在幕后,此命令会更新 .git/refs/remotes/origin/HEAD 中的引用。
有关更多详细信息,请参阅 git-remote 手册页。
The error occurs when your repository does not have the default branch set for the remote. You can use the
git remote set-head
command to modify the default branch, and thus be able to use the remote name instead of a specified branch in that remote.To query the remote (in this case
origin
) for itsHEAD
(typicallymaster
), and set that as the default branch:If you want to use a different default remote branch locally, you can specify that branch:
Once the default branch is set, you can use just the remote name in
git rebase <remote>
and any other commands instead of explicit<remote>/<branch>
.Behind the scenes, this command updates the reference in
.git/refs/remotes/origin/HEAD
.See the git-remote man page for further details.
对我来说,指定分支有帮助。
For me, to specify branch helps.
git 子模块 deinit --all -f
为我工作。
git submodule deinit --all -f
worked for me.
$ git rebase upper/master
fatal: Needed a single revision
invalid upper usptream/master**
所以我尝试了 $ git rebaseremotes/upstream/master 它对我有用。
$ git rebase upstream/master
fatal: Needed a single revision
invalid upstream usptream/master**
So I tried $ git rebase remotes/upstream/master and it works for me.