我看到了问题How to reverse apply a stash?询问者 Pat Notz 。我已经尝试过批准的答案,但出现这样的错误,
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
应用存储后,我的文件中存在这样的冲突,
<<<<<<< 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
=======
然后我用谷歌搜索如何恢复它。我进来的问题是How to reverse apply a stash?询问者 Pat Notz ,并尝试解决该问题。
我想知道有没有办法在执行 sudo git stash apply
之前恢复状态,就在执行 git add .
之后或之前
最佳答案
您应该简单地重新存储,然后 git reset (甚至是 git reset --hard
,前提是您先存储了),如“Aborting git stash apply
”中所述。
如果您在没有先存储的情况下执行reset --hard
,您仍然可以在.git/refs/stash
中看到您的补丁,如“Undo git reset --hard
after git stash pop
”中所述。 “(通过 git stash apply
无论如何都不会从存储中删除补丁,就像 git stash pop
那样,所以在这里你不必担心),或you can recover it from git fsck
.
I want to roll back the state before execute the
sudo git stash apply
由于 git apply --reverse
不起作用,最好按照我上面的建议返回 HEAD,然后重做您的操作。
关于git - 如何反向应用有冲突的存储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38500971/