0

私は彼らが提供するGITに1und1.deサービスを使用しています。今、私はそれを設定していて、コマンドgit pull ssh:// .........を使用して、そこからローカルコンピューターに変更をプルしました。

しかし、git push ssh:// ......を実行しようとすると、多くのエラーが発生しました。

remote: error: refusing to update checked out branch: refs/heads/master
remote: error: by default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree incosistent

Auto packing the repository for optimum performance.remote: error: with what you pushed, and will require 'git  reset --hard' to match

remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' Configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you arranged to update its work tree to match waht you pushed in some other way.

remote: error: to sqelch this message and still keep the default behaviour, set
remote: error: receive.denyCurrentBranch' configuration variable to 'refuse'.
! [remote_rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://........' 
4

2 に答える 2

1

プッシュするリポジトリを設定するときは、リポジトリとして設定しbareます。

git init --bare

作業ディレクトリを使用してリポジトリにプッシュすることは技術的には可能ですが、それはあまりにも頭痛の種であり、この場合、あなたはそれさえ望まないでしょう。

リポジトリをベアリポジトリとして再作成するか、リポジトリからベアリポジトリを作成するだけです(git clone --bare /path/to/repo

于 2013-03-23T19:10:09.420 に答える
1

Gitリポジトリには2つのタイプがあります。ベアリポジトリは通常呼び出され、Gitのfoo.git内部ファイルだけで、作業ツリーはありません。非ベアリポジトリは、作業ツリー(つまり、すべてのファイルを含むディレクトリ)であり、。という名前のディレクトリも含まれています.git。エラーメッセージで説明されているように、ベアでないリポジトリにプッシュすることは通常は悪い考えです。そうすると、作業ツリーがリポジトリに対して古くなるためです。

人々がプルしたりプッシュしたりするためのリポジトリをホストしている場合、ほとんどの場合、ベアリポジトリが必要です。この場合、ベア以外のリポジトリを作成したようです。リポジトリの作成方法の詳細を提供していないため、何が間違っていたかはわかりませんが、次の2つの方法のいずれかでベアリポジトリを作成できます。

  1. リポジトリを作成するディレクトリから、を発行しgit clone --bare path/to/original.gitます。original.gitこれにより、現在のディレクトリ内のベアリポジトリにソースのクローンが作成されます。
  2. リポジトリを作成するディレクトリから、を発行しgit init --bare foo.gitます。foo.gitこれにより、現在のディレクトリ内に空のベアリポジトリが作成されます。

できることは他にもありますが、正しく理解するのが最も簡単です。既存のリポジトリ内で発行git config --set core.bare falseすると、Gitはそれ以降はベアリポジトリであると見なしますが、作業ツリーを自分で削除する必要があり、おそらくリポジトリの名前をから.gitに変更する必要がありますfoo.git

于 2013-03-23T19:10:40.450 に答える