I have seen the question How to reverse apply a stash? asked by Pat Notz. And I have tried the approved answer, but I get such an error,
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
I have to explain how I run in this situation.
I have a stashes in my stash list, and I have do some modify in my working repository. The changes in my working repository have conflict with the stash@{0}. Then I execute the git add .
and sudo git stash apply
commands by fault, and it shows this info,
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
After the stash apply, there is conflict in my file like this,
<<<<<<< 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
=======
Then I google how to revert it. I come in the question How to reverse apply a stash? asked by Pat Notz, and tried the solution of that question.
I want to know is there a way to rool back the state before execute the sudo git stash apply
, just after or before execute git add .