git-rev-list man page显示以下命令:
$ git rev-list origin..HEAD
$ git rev-list HEAD ^origin
但是,当我运行第一个命令时,出现以下错误:
$ git rev-list origin..HEAD fatal: ambiguous argument 'origin..HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'
“origin”指的是以下远程:
$ git remote -v
origin c:/hands_on/git/learn/clone/../repo_1 (fetch)
origin c:/hands_on/git/learn/clone/../repo_1 (push)
我使用的命令不正确吗?另外,我认为 rev-list 命令将提交作为输入,所以我不清楚为什么手册页使用“origin”,而“origin”是远程的。我误解了什么?
最佳答案
git-rev-parse(1) 解释了如何将远程名称用作引用:
<refname>, e.g. master, heads/master, refs/heads/master
A symbolic ref name. E.g. master typically means the commit object
referenced by refs/heads/master. If you happen to have both heads/master and
tags/master, you can explicitly say heads/master to tell Git which one you
mean. When ambiguous, a <refname> is disambiguated by taking the first match
in the following rules:
1. If $GIT_DIR/<refname> exists, that is what you mean (this is usually
useful only for HEAD, FETCH_HEAD, ORIG_HEAD, MERGE_HEAD and
CHERRY_PICK_HEAD);
2. otherwise, refs/<refname> if it exists;
3. otherwise, refs/tags/<refname> if it exists;
4. otherwise, refs/heads/<refname> if it exists;
5. otherwise, refs/remotes/<refname> if it exists;
6. otherwise, refs/remotes/<refname>/HEAD if it exists.
git-remote(1) 解释了什么 refs/remotes/<remote>/HEAD
在git remote set-head
的描述中:
set-head
Sets or deletes the default branch (i.e. the target of the symbolic-ref
refs/remotes/<name>/HEAD) for the named remote. Having a default branch
for a remote is not required, but allows the name of the remote to be
specified in lieu of a specific branch. For example, if the default
branch for origin is set to master, then origin may be specified wherever
you would normally specify origin/master.
换句话说,它使用远程的默认分支,而您似乎没有。
关于git - "git rev-list origin..HEAD"应该返回什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32681992/