git登录并在裸露的回购站点上显示 [英] git log and show on a bare repo

查看:96
本文介绍了git登录并在裸露的回购站点上显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地网络的文件服务器上创建了一个裸存储库。
在此之后,我将现有资源库的一个分支从我的desktop-pc推送到这个新的远程资源库。



推送工作完美,看起来,所有数据到达(git分支-va给了我正确的数据)。
但我不能在裸仓库上使用git log或git show。
i get a:
$ b $ p $ fatal:错误的缺省版本'HEAD'



或者根本没有输出



这对裸仓库来说是正常的吗?是否有另一种可能性来显示所有内容?

编辑:
致命错误现在已解决,但我从git log或git log不稳定。相同的命令在桌面PC上完美地工作

解决方案

是的,这对于新裸露(和非裸露)存储库是正常的。

说明



HEAD 是Git所谓的 — c>通常表示哪个分支当前被检出。一个新的提交会导致由 HEAD 命名的分支被提前引用新的提交。当 HEAD 直接引用一个提交对象而不是一个分支时,它被认为是分离的,这意味着进一步的提交不会导致分支引用为高级来引用新的提交(危险是因为签出不同的提交或分支会导致任何现有引用无法访问新的提交,使他们很难找到并进行垃圾回收)。



在裸存储库中, HEAD 指示存储库的默认分支,因此在存储库的克隆中 git checkout origin master 是默认分支,则$ c>相当于 git checkout origin / master >

当Git初始化一个新的存储库时,它初始化 HEAD code>引用 refs / heads / master (换句话说, HEAD 指向 master 默认分支)。但是,它不会创建名为 master 的分支,因为 master 存储库中没有提交指向。

因此,除非您创建 master 分支或更改 HEAD 指向一个存在的分支,当你运行一个看起来 HEAD 的命令时(例如 git 或 git show 不带任何参数)。



您仍然可以使用命令不要检查 HEAD 。例如:

  git log some_branch_that_exists 



修正



要摆脱错误讯息,您可以执行以下操作之一:


  • 更改 HEAD 以指向确实存在的分支:

      git symbolic-ref HEAD refs / heads / some_other_branch 


  • 将新的 master 分支从其他地方推送到存储库中 创建新的 master 本地分支:

      git branch master some_existing_commit 



  • 可视化



    我使用这样的东西:

      git log --graph --oneline --date-order --decorate  - -color  -  all 

    请注意,即使 HEAD 指向一个不存在的分支。


    I created a bare repository on a file-server in my local network at home. After this i pushed a branch of an existing repository from my desktop-pc to this new remote repository.

    Pushing worked perfectly and it seems, that all data arrived (a "git branch -va" gives me the correct data). But i cannot use git log or git show on the bare repository. i get an:

    fatal: bad default revision 'HEAD'

    or simply no output

    is this normal for bare repositories? Is there another possibility to visualize everything?

    Edit: The fatal error is solved now, but i receive no output from "git log" or "git log unstable". Same command on the desktop-pc works perfectly

    解决方案

    Yes, this is normal for new bare (and non-bare) repositories.

    Explanation

    HEAD is what Git calls a symbolic reference—a reference to another reference.

    In non-bare repositories, HEAD normally indicates which branch is currently checked out. A new commit will cause the branch named by HEAD to be advanced to refer to the new commit. When HEAD refers to a commit object directly instead of a branch, it's considered to be detached, meaning further commits will not cause a branch reference to be advanced to refer to the new commits (dangerous because checking out a different commit or branch will render the new commits unreachable by any existing reference, making them hard to find and subject to garbage collection).

    In bare repositories, HEAD indicates the repository's default branch, so that in a clone of the repository git checkout origin is equivalent to git checkout origin/master if master is the default branch (see git help rev-parse for details).

    When Git initializes a new repository, it initializes HEAD to refer to refs/heads/master (in other words, HEAD points to the master branch by default). However, it does not create a branch named master because there are no commits in the repository for master to point to yet.

    So until you either create a master branch or change HEAD to point to a branch that does exist, you'll get that error when you run a command that looks at HEAD (such as git log or git show without any arguments).

    You can still use commands that don't examine HEAD. For example:

    git log some_branch_that_exists
    

    Fix

    To get rid of the error message, you can do one of the following:

    • Change HEAD to point to a branch that does exist:

      git symbolic-ref HEAD refs/heads/some_other_branch
      

    • Push a new master branch into the repository from somewhere else
    • Create a new master branch locally:

      git branch master some_existing_commit
      

    Visualization

    To visualize everything in the repository, I use something like this:

    git log --graph --oneline --date-order --decorate --color --all
    

    Note that the above command will work even if HEAD is pointing to a non-existent branch.

    这篇关于git登录并在裸露的回购站点上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆