私は通常とは異なるマシンで開発しています.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 status
とgit 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
...この場合には言及役立つことをgitのだろう。私は 'git fetch --unshallow'ヒントを私の他の答えにも追加します。 – torek