44

OK、スタックオーバーフローで見つけたすべての答えを試しましたが、どうやら私の問題を解決できるものはないようです。SVNで作成したパッチをgitリポジトリに適用したい。どうやらそれを行う最も簡単な方法は「git apply」を使用することですが、それはうまくいかないようです。

$ git apply --ignore-space-change --ignore-whitespace < xxx_parser.patch


<stdin>:10: trailing whitespace.
        FORCE_LA_CHECK = false; stdin:23: trailing whitespace.

<stdin>:79: trailing whitespace
. 
. 
. 
. 
error: pmd/grammar/JspParser.jjt: No such file or directory 
error: patch failed: pmd/pom.xml:251 
error: pmd/pom.xml: patch does not apply

これは xxx_parser.patch の内容です:

 $ head xxx_parser.patch Index: etc/grammar/JspParser.jjt
 --- etc/grammar/JspParser.jjt   (revision 7704)
 +++ etc/grammar/JspParser.jjt   (working copy)

ファイル pmd/grammar/JspParser.jjt が見つからないと不平を言うのはなぜですか?

パッチ内のパスは適切なディレクトリを指しています。

4

2 に答える 2

53

SVN で生成されたパッチを git に適用する際にいくつかの問題がありました。サブバージョンのパッチをコマンドで直接適用しpatch、git を使用してそのパッチが正常に適用されたことを確認することをお勧めします。

$ patch -p0 < xxx_parser.patch
$ git diff
于 2012-07-25T14:51:03.970 に答える
9

patchコマンドラインに実行可能なコマンドがある場合、@emcconvilleの回答は機能します。

ほかの人のため:

  1. svn リポジトリに移動します

    svn diff --git >> gitFormat.patch

  2. あなたの(このファイルをにコピーする)gitリポジトリから

    git apply gitFormat.patch

于 2015-01-07T10:25:28.990 に答える