1

ローカル マシンに と という 2 つのレポがlocal1ありlocal2ます。だから私は逃げたlocal1

git push local2 sombranch

そして私はこれを手に入れました

remote: error: refusing to update checked out branch: refs/heads/5-0-stable
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.

2 つのリポジトリの歴史はほぼ同じであり、わずかな違いが競合に発展することはありませんでした。を変更する必要がありreceive.denyCurrentBranchますか? このコマンドでリモートリポジトリを裸のリポジトリに変えたくありませんgit config --bool core.bare true

4

1 に答える 1

1

local2 を裸のリポジトリにしたくない場合は、いくつかの選択肢があります。

1) を設定しreceive.denyCurrentBranchます。しかし、git エラー メッセージは、これが後で問題を引き起こす可能性があることを明確に説明していると思うので、おそらく回避するのが最善です。

2) local2 の別のブランチをチェックアウトしてから、local1 からプッシュします。このエラーは、リモート リポジトリでチェックアウトされているブランチにプッシュしようとした場合にのみ発生するため、別のブランチをそこにチェックアウトすることで回避できます (これにより、エラーで説明されている作業ツリー/HEAD 同期の問題も解消されます)。 .)

3) local2 からのおそらく最も簡単な方法は、次のとおりです。

git pull local1

は HEAD、インデックス、作業ツリーの 3 つすべてを更新するため、 HEAD のみを変更する のgit pullような同期の問題はありません。git push

于 2013-06-19T13:47:03.243 に答える