2

スタッシュを逆に適用するにはどうすればよいですか?という質問を見てきました。パット・ノッツの質問。そして、承認された回答を試しましたが、このようなエラーが発生し、

sudo git stash show -p | git apply --reverse
    error: patch failed: app/controllers/CloudController.php:673
    error: app/controllers/CloudController.php: patch does not apply
    error: patch failed: app/controllers/CloudGcode.php:1
    error: app/controllers/CloudGcode.php: patch does not apply

この状況でどのように走るかを説明しなければなりません。スタッシュ リストにスタッシュがあり、作業リポジトリでいくつかの変更を行いました。作業リポジトリの変更が stash@{0} と競合しています。次に、フォルトでコマンドgit add .とコマンドを実行すると、次の情報が表示されます。sudo git stash apply

sudo git stash apply
[sudo] password for xxxx:
    Auto-merging app/controllers/CloudGcode.php
    CONFLICT (add/add): Merge conflict in app/controllers/CloudGcode.php
    Auto-merging app/controllers/CloudController.php
    CONFLICT (content): Merge conflict in app/controllers/CloudController.php

stash が適用された後、このように私のファイルに競合があります。

<<<<<<< Updated upstream
            for($i = 0; $i < $textlen; $i++)
            {
                $char = $uchars[$index++];
                if($char !== 0)
                    $text = $text.chr($char);
            }
            $this->text = $text;
Log::info('LLLLLLLLLLLLLLLLLLLL'.$text);
=======
            for($i = 0; $i < $this->textlen; $i++)
                $text = $text.$uchars[$index++];
            $this->text = $text;
            $this->text[$this->textlen] = 0; // Terminate string overwriting checksum
>>>>>>> Stashed changes
            $this->waitUntilAllCommandsAreParsed = true; // Don't destroy string until executed
        }
        $this->formatErrors = 0;
        return true;
    }
<<<<<<< Updated upstream
=======

次に、元に戻す方法をグーグルで検索します。スタッシュを逆に適用する方法は? Pat Notzに質問され、その質問の解決策を試しました。sudo git stash apply実行前、実行直後または実行前に状態をロールバックする方法があることを知りたいgit add .

4

1 に答える 1

3

「中止」で述べたように、単純に再スタッシュしてから git reset (またはgit reset --hard、最初にスタッシュした場合は ) を実行する必要があります。git stash apply

reset --hard最初にスタッシュせずにa を実行すると、「後で元に戻す.git/refs/stashで説明されているように、まだパッチが に表示されます ( a はスタッシュからパッチを削除しないため、ここではそれについて心配する必要はありません)。 )、またはから復元できますgit reset --hardgit stash popgit stash applygit stash popgit fsck

実行前に状態をロールバックしたいsudo git stash apply

git apply --reverseがうまくいかないので、上記で提案したように HEAD に戻って、操作をやり直すのが最善です。

于 2016-08-22T06:29:03.133 に答える