Helix4Git管理者ガイド (2019.1)

プッシュの結果HEAD refが存在しないというメッセージが表示される

以下のコマンドを実行します。

$ git push git@ConnectorHost:gD1/repo8 main

結果:

Counting objects: 3, done.
Writing objects: 100% (3/3), 226 bytes \| 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: HEAD ref is "refs/heads/master", but this ref does not exist.
remote: Consider asking the admin for repo "gD1/repo8.git"
remote: to set its default branch to a valid ref so that
remote: "git clone" and "git checkout" can check out
remote: without specifying a branch name.
To git@xx.x.xx.xxx:repo/grepo1
 * [new branch]      main -> main

この問題を解決するには、以下のいずれかを実行します。

  • リポ仕様を編集して、refs/heads/mainをデフォルトブランチとして指定し、ここからクローンを作成します。 これは、refs/heads/masterデフォルトブランチを使用していないプロジェクトに必要です。 詳細については、デフォルトのブランチを指定を参照してください。
  • 以下の特別なコマンドを実行して、デフォルトブランチをrefs/heads/mainに設定します。

    $ git clone git@ConnectorHost:@defaultbranch:gD1/repo8=refs/heads/main

    この結果、以下が出力されます。

    git clone git@ConnectorHost:@defaultbranch:gD1/repo8=refs/heads/main
    Cloning into 'main'...
    repo='gD1/repo8', old DefaultBranch='', new DefaultBranch='refs/heads/main'
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights and the repository exists.
    注意

    この特別なコマンドは標準的なGit構文ではないため、Gitがこれを解析できず、次によりこのコマンドは終了されます。

    Fatal: Could not read from remote repository.

    @defaultbranch:gD1/repo8を実行してデフォルトブランチを表示し、@defaultbranch:gD1/repo8=を実行してデフォルトブランチをクリアすることもできます。