git藏匿处 - 本地变化 - git储藏 - git储藏应用 - 撤消

发布于 2025-02-10 05:43:51 字数 235 浏览 1 评论 0原文

需要一些帮助,我搞砸了。请保留判断。

好吧,这就是我所做的。

  1. git stash

  2. 对代码进行了一些更改。

  3. git储藏(再次)

  4. git储藏应用

是否有任何方法可以回到第一个Git藏匿之前的代码。

任何帮助将不胜感激。

提前致谢。

Need some help, I screwed up. Please reserve judgement.

Alright, this is what I did.

  1. git stash

  2. made some changes to the code.

  3. git stash (again)

  4. git stash apply

Is there any way I can get back to the code I had before the first git stash.

Any help would be appreciated.

Thanks, in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等待我真够勒 2025-02-17 05:43:51
git stash list
<shows all the saved stashes>

git stash show 'stash{0}'
<displays changes in this stash>
<change index according to the one you want, 0 is the last saved stash>

git stash apply 'stash{0}'
<applies the stash>
git stash list
<shows all the saved stashes>

git stash show 'stash{0}'
<displays changes in this stash>
<change index according to the one you want, 0 is the last saved stash>

git stash apply 'stash{0}'
<applies the stash>
茶底世界 2025-02-17 05:43:51

欣赏应用或弹出git储藏只会改变工作目录和/或阶段。它不会做出新的提交。因此,简单地进行硬重置应该让您回到第一个藏匿之前的位置:

# from your branch
git reset --hard

话:如果您想保留自第一个藏匿以来的变化列入,那是另一个故事并且需要更多的工作和思考才能实现。

注意:一般而言,弹出git藏匿处是有风险的,因为如果一路走了问题,就无法重新涂上与已经从堆栈中弹出的藏匿处。使用git存放应用以获得最佳结果。

Appreciate that applying or popping a Git stash just alters the working directory and/or stage. It does not make a new commit. Therefore, simply doing a hard reset should get you back to where you were before the first stash:

# from your branch
git reset --hard

That being said, if you wanted to retain some permutation of the changes since the first stash, that is another story and would require more work and thought to pull off.

Note: Generally speaking, popping a Git stash is risky, because if something goes wrong along the way, you can't reapply the same stash as it has already been popped from the stack. Use git stash apply for best results.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文