gpt4 book ai didi

git - "git rev-list origin..HEAD"应该返回什么?

转载 作者:太空狗 更新时间:2023-10-29 14:32:13 27 4
gpt4 key购买 nike

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' 指的是以下 Remote :

$ 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'。我误解了什么?

最佳答案

git-rev-parse(1) 解释了如何将远程名称用作 ref:

<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>/HEADgit 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com