私は SVN から来ましたが、Git 全体がどのように機能するかを理解していません。リモート リポジトリを作成し、ローカル マシンでリポジトリのクローンを作成しました。ローカル マシンでファイルに変更を加え、それらのファイルをクローン元の正確なリモート リポジトリにプッシュしようとすると、このようなエラーが発生します。
リモート: エラー: チェックアウトされたブランチの更新を拒否しています: refs/heads/master
同じ問題に関するいくつかのSOの質問を閲覧しましたが、最も一般的な解決策は、ベアリポジトリを作成してからコミットすることでした. では、その新しいレポからクローンを作成するとどうなりますか?これは再び起こりますか? ローカルからのコミットごとに新しい裸のリポジトリを作成し続ける必要がありますか? 私は混乱しています。誰かが私を正しい方向に向けることができれば、それは素晴らしいことです. 私はこれを完全に間違っていると思います。
私が従っている正確な手順:1)リモートサーバーにディレクトリを作成しました-gitリポジトリとしてinit 2)必要なすべてのコンテンツをサーバーにコピーしました3)コンテンツをgitに追加し、そこにコミットしました4)gitリポジトリをリモートから自分にクローンしましたローカル マシン 5) ローカルのファイルに変更を加え、その変更をローカルに追加してコミットしました。6) git push origin を使用して、ローカルで行った変更をリモートにプッシュしようとすると、エラー メッセージが表示されます。以下にエラーメッセージ全体を提供します。
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: Auto packing the repository for optimum performance.
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'.
! [remote rejected] master -> master (branch is currently checked out)