2016-11-23 15 views
1

私は通常とは異なるマシンで開発しています.gitは私が思うのとは違った動作をしているようです。git statusとgit diffが失敗した後で空になる

私は新しいブランチgit checkout -b <new branch name>をチェックアウトし、パッチgit am </path/to/file.patch>を適用しようとすると、パッチが適用に失敗:

</path/to/file.patch> 
Applying: <commit msg> 
error: patch failed: <filename>:<line no> 
error: <filename>: patch does not apply 
Patch failed at <commit msg> 
The copy of the patch that failed is found in: .git/rebase-apply/patch 
When you have resolved this problem, run "git am --continue". 
If you prefer to skip this patch, run "git am --skip" instead. 
To restore the original branch and stop patching, run "git am --abort". 

パッチが適用に失敗したときに今、私は私の他のマシンに誓う、git statusgit diffそのファイルが<<<HEAD>>>>のマーカーで修正されたものとして表示され、3方向マージを修正する必要がある場所が示されます。現在git statusは、am操作の途中ですが、git diffのようにファイルが変更されていないことを示しています。

私は覚えていませんか、私の他のマシンはgitの古いバージョンか、あるいは別の設定オプションセットさえありますか? gitはなぜマージ競合を表示しないのですか?私はmergetoolを設定する必要がありますか?私は現時点では私の他のマシンにアクセスできないが、できる限り私はこの情報をより多くの情報で更新しようとしている。

編集:

git am --3wayは、私が欲しいもののようです。 [0] [1]しかし、git am --3way <path/to/patch>git config --global am.threeWay trueも動作していないようです。

ああ、それは今別のメッセージで失敗しています:

</path/to/file.patch> 
Applying: <commit msg> 
fatal: sha1 information is lacking or useless (<filename>).   <-- new 
error: could not build fake ancestor         <-- new 
Patch failed at <commit msg> 
The copy of the patch that failed is found in: .git/rebase-apply/patch 
When you have resolved this problem, run "git am --continue". 
If you prefer to skip this patch, run "git am --skip" instead. 
To restore the original branch and stop patching, run "git am --abort". 

Similary、git am --3way </path/to/patch>がで失敗します。

error: patch failed: <file>:<lineno> 
error: repository lacks the necessary blob to fall back on 3-way merge. 
error: Makefile: patch does not apply 

たぶん、このパッチは回復できないのですか? patch -p1 < </path/to/path>に行くと、最初のハンクが適用され、2番目のハンクでは失敗するので、手で行う必要があります。

私は--depth 1でクローン化された浅いレポから作業していることに注意してください。

[0] https://www.kernel.org/pub/software/scm/git/docs/git-am.html [1] https://www.kernel.org/pub/software/scm/git/docs/git-config.html

答えて

2

なるほど!間違ってThis SO post led me to an answer.

2つのこと:

は三方が git amのデフォルトの動作としてマージ設定:

git config --global am.threeWay true

これは私が(すなわちシャローコピーを行っていたという事実によって混乱されました。 --depth 1)。十分な歴史がなければ、fatal: sha1 information is lacking or uselessという警告は、「3ウェイマージを構築するのに十分な情報ではない」と言っています。

あなたはより多くの歴史をフェッチするシャローコピーを行っていた場合には、メッセージ自体は確かにアップ強化しする必要が

+0

...この場合には言及役立つことをgitのだろう。私は 'git fetch --unshallow'ヒントを私の他の答えにも追加します。 – torek

関連する問題