2016-09-11 10 views
2

私はちょうどGitを学んでいるので、私に同行してください。私はローカルでいくつかのコードを書いて、私は今私のリモートサーバ(origin)にプッシュしたいと思います。私はこのエラーを取得する:Gitを学ぶ:リモートは適切な設定にもかかわらずプッシュを拒否しますか?

! [rejected] master -> master (fetch first)

error: failed to push some refs to 'ssh://[email protected]:2200/home/user'

Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing

リモコンはv 2.4.1であり、この設定(git config --listの出力)を持つ:

core.repositoryformatversion=0 
core.filemode=true 
core.bare=false 
core.logallrefupdates=true 
receive.denycurrentbranch=updateInstead 

い私は上げずconfictsをオーバーライドするために許されるべきではない最後の平均エラー?

私は基本的に最も簡単な設定を探しています。私はサーバー上で開発することはなく、私はアクセスできる唯一の人です。だから、開発マシンが勝つためにプッシュするものは何でもします。

this answerは、リモートのリポジトリを裸にすることを見ましたが、指示はフォルダ内のすべてを削除することでしたが、.gitです。私のプロジェクトの一部ではないそこにファイルがあるので、それは私のために動作しませんが、私は、リモートリポジトリにログインした場合

を移動し、私が見git status実行しないことを

Untracked files: (use "git add ..." to include in what will be committed)

...(long list of files)

nothing added to commit but untracked files present (use "git add" to track)

私はちょうどでした補遺

$ git push --force origin master 
stdin: is not a tty 
Counting objects: 3801, done. 
Delta compression using up to 8 threads. 
Compressing objects: 100% (3674/3674), done. 
Writing objects: 100% (3801/3801), 6.95 MiB | 37.00 KiB/s, done. 
Total 3801 (delta 2450), reused 0 (delta 0) 
error: Untracked working tree file 'cacert.pem' would be overwritten by merge. 
To ssh://[email protected]:2200/home/user 
! [remote rejected] master -> master (Could not update working tree to new HEAD) 
error: failed to push some refs to 'ssh://[email protected]:2200/home/' 

私はちょうどそれ自体を削除することができます思っていますそのファイルのrverのコピーをもう一度やり直してください。 2つのファイルは(それがコピー/ペースト仕事だった)と同じ内容を持つ

答えて

1

I don't want the local to import any change from the remote I want local files to overwrite remote files

provblemは、あなたがプルをgitのしたくない場合は、あなたが必要とする、というエラーメッセージが表示され、次のとおりです。

git push --force 

しかし、ファイルを上書きするだけではなく、コミットによってリモート側のコミットの最近の履歴を上書きするので、それが確かにあなたが望むものであることを確認してください。

the remote has setting receive.denycurrentbranch=updateInstead . Doesn't that mean that my push should just update the remote master branch?

、非裸のレポ(「プッシュデプロイ」約see more here)にプッシュすることを可能にするが、エラーメッセージがそれについてではありません。
ローカルにないリモート側のコミットについてです。

通常、pull --rebaseは、更新されたフェッチされたリモートブランチの上で変更を再生します。 次にを押します。

+0

omg私はあなたの最初のコマンドを実行し始めました - 私たちが話しているように動いていて、編集後に編集していたことに気付きました。 lol – BeetleJuice

+0

私の元のコマンドよりもかなり混雑していましたが、 '--force'でも動作しませんでした。私はOPで結果を更新しました。 – BeetleJuice

+0

@BeetleJuice Novelie:リモートのリポジトリには、reflogにコミットの古い履歴が残っています。何も失われません。 – VonC

関連する問題