1

サーバー上に Web サイトがあり、作品の共有を開始したいので、git を使用しています。私はそれにとても慣れていません。

そのため、リモート サーバーで、「git init」と git commit を作成して、すべての作業を .git ディレクトリ (常にリモート サーバー上) に移動しました。

次に、ローカル サーバーで (ssh 接続を使用して) git クローンを作成しました。そして、いくつかのファイルを変更してコミットし(正常に動作しました)、プッシュしましたが、エラーメッセージは次のとおりです。

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 inconsistent
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
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ssh://sameditr@ftp.sameditresfroid.fr/homez.501/sameditr/www/.git
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh:...'

誰かアイデアはありますか?

ベスト、ニューベン

4

2 に答える 2

1

私は通常、次のことを行います。

サーバー上、webapp ディレクトリ内

$ git init
$ git add *
$ git commit -a

少なくとも初期コミットを持つ

開発用コンピューターでは、次のことができます。

$ git init
$ git remote add origin git+ssh://server/var/www/.git/
$ git branch --set-upstream master origin/master
$ git pull

dev でファイルを編集する

$ git push

お役に立てれば!

于 2012-10-20T23:41:49.007 に答える
1

リモート サーバーに中央リポジトリを作成する場合は、ベアリポジトリを作成する必要があります。

git init --bare

更新を受け入れるように現在の非ベア リポジトリを構成できます (エラー メッセージに方法が示されています) が、はるかに簡単な方法は、リモート サーバー上の現在のリポジトリを削除し、新しいベア リポジトリを作成することです。

ベアリポジトリと非ベアリポジトリの違いの詳細な説明へのリンクは次のとおりです。

于 2012-05-16T11:07:22.663 に答える