3

何が起こったのか完全にはわかりませんが、何らかの理由でgitリポジトリのマスター参照ファイルが空になりました。Dropboxでリポジトリをホストしているので、それと関係があるかもしれませんが、今はそこからプルできません。それはこれを言います:

Your configuration specifies to merge with the ref 'master' from the remote, but no such ref was fetched.

Dropboxはファイルのバージョンを保持しているので、以前のバージョンの「マスター」に戻ると、次のように表示されます。

fatal: object 2d154f82e59a4156a5d3ea04a0617c243ae6dc3a is corrupted
fatal: The remote end hung up unexpectedly

これからどのように回復しますか?

4

1 に答える 1

7

はぁ。

私はDropboxが好きですが、Gitリポジトリの「ホスティング」には決してお勧めしません。その同期は単一ファイルのドキュメントには十分に機能しますが、Gitリポジトリの安全なホスティングに必要な分散/リモートファイルシステムのセマンティクスを提供することにはほど遠いです。

うまくいけば、Dropboxで裸のGitリポジトリを「ホスト」しているだけです。もしそうなら、あなたはあなたの非裸の(動作している)リポジトリからのコミットと参照を一緒にまとめることができるはずです。既存のリポジトリを手動でリカバリすることも可能ですが、とにかく他のリポジトリからオブジェクトをコピーする必要がある可能性が高いため、(「低レベル」にするのではなく、次の「高レベル」の方法で行う方がよいでしょう。他のリポジトリからオブジェクトをコピーする(またはパックファイルをコピーしてその一部を解凍する))。

作業ディレクトリの1つの独立したクローンを作成することから始めます。

git clone file://path/to/myrepo /path/to/myrepo-recovery-work

他の作業リポジトリから参照とオブジェクトをインポートします。

# If you have network access to the other repositories:
cd /path/to/myrepo-recovery-work
git remote add other1 user@machine:path/to/other/working-repo-1
git remote add other2 ssh://user@machine/path/to/other/working-repo-2
# etc.
git fetch --all


# If you do not have network access:
cd /path/to/other/working-repo-1 &&  # on machine with working-repo-1
  git bundle create /path/to/other1.gitbundle --all HEAD
cd /path/to/other/working-repo-2 &&  # on machine with working-repo-2
  git bundle create /path/to/other2.gitbundle --all HEAD
# etc.
# Transfer the bundle files to the machine that has "myrepo-recovery-work"
# (Dropbox is OK to copy the bundles, they are just single files),
# then on that machine:
cd /path/to/myrepo-recovery-work
git remote add other1 /path/to/transferred/other1.gitbundle
git remote add other2 /path/to/transferred/other2.gitbundle
# etc.
git fetch --all

次に、新しいリモートのすべてのブランチを調べて、再構築された中央リポジトリのどのコミットをどのブランチが指すかを決定します。

git log --oneline --graph --decorate --abbrev-commit --all
# In addition to looking at the history graph, you might need to examine
# the content of certain commits. Just check them out as a detached HEADs.
git branch recovered/maintenance decafbad
git branch recovered/master cafebabe
git branch recovered/development deadbeef
git branch recovered/bug-1234 8badf00d

復元したブランチ(およびタグ)を作成して、新しいベアリポジトリにプッシュします。

git init --bare /path/to/new-central-bare-repo.git # or real Git hosting service!
git remote add new /path/to/new-central-bare-repo.git
git push --tags new 'refs/heads/recovered/*:refs/heads/*'
于 2011-03-09T05:21:39.547 に答える