结帐后获取提交的更改

发布于 2024-10-31 01:41:40 字数 172 浏览 5 评论 0原文

有什么方法可以获取我在签出新分支时留下的未提交的更改(愚蠢,我知道!!)

我切换回了我所在的分支,并且我仍然有以下消息,让我相信它们可能在某个地方我能到!

    M   app-switcher.tmproj
    M   as_user_check.php

is there any way to fetch uncommited changes I left when I checkout out a new branch (dumb, I know!!)

I switched back the branch I was on, and I still have the following message, leading me to believe they might be somewhere I can get to!

    M   app-switcher.tmproj
    M   as_user_check.php

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

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

发布评论

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

评论(1

寂寞笑我太脆弱 2024-11-07 01:41:40

如果您从一个分支切换到另一个分支,并且分支的更改不会影响您在工作树中修改的文件,那么这些文件的工作副本也不会受到影响。您从 git checkout 看到的输出提醒您这一点。

要查看这些文件中未暂存的更改,您只需执行以下操作:

git diff

...并且您只需签出要将这些更改提交到的分支,然后git addgit commit 像往常一样。

一个可能造成混淆的原因是,如果更改已暂存,您将看到相同的输出(带有 M 前缀)。在这种情况下,要查看更改,您必须执行以下操作:

git diff --cached

在这种情况下,您只需使用 git checkout 切换到正确的分支,并使用 git commit 提交这些更改代码>.如果您想取消暂存更改,您可以执行以下操作:

git reset HEAD -- as_user_check.php

...,因为 git status 的输出会提示您。

If you switch from one branch to another, and the change of branches wouldn't affect files that you've modified in your working tree, your working copy of those files won't be affected. The output that you see from git checkout is reminding you of that.

To see the unstaged changes in those files, you can just do:

git diff

... and you can just checkout the branch you want to commit those changes to and git add and git commit as usual.

One possible source of confusion is that you'll see the same output (with an M prefix) if the changes have been staged. In that case, to see the changes, you'll have to do:

git diff --cached

In that case, you can just switch to the right branch with git checkout and commit those changes with git commit. If you want to unstage the changes, you can do:

git reset HEAD -- as_user_check.php

... as the output of git status should prompt you.

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