git:根据分支冻结/解冻工作目录

发布于 2025-01-16 11:28:44 字数 317 浏览 4 评论 0原文

我正在使用 git 开发一个功能,为此我创建了一个 topic/1 分支

该功能的开发已停止,因为我正在等待响应 我的工作目录中有很多更改,这些更改是临时的,我不想保存在提交中,但我也不想在返回开发 topic/1 时丢失这些更改,

我如何切换到新的 topic/2 分支,当我返回 topic/1 时,返回到我离开时的工作目录? 我想保持分支显示干净并避免添加临时提交。

请记住,在执行 topic/2 时可能会发生这种情况。示例我收到主题/1 的响应,我想冻结主题/2 并解冻主题/1,而不丢失工作目录中的更改并保持提交树干净

处理此工作流程的正确方法是什么?

I am working with git developing a feature, for this I have created a topic/1 branch

The development of this feature has been stopped, as I am waiting for a response
I have a lot of changes in my working directory that are temporary things, that I don't want to save in a commit but I also don't want to lose when I go back to developing topic/1

How could I switch to a new topic/2 branch, and when I go back to topic/1, return to the working directory as I left it?
I would like to keep the branch display clean and avoid adding temporary commits.

Keep in mind that this situation can happen when doing topic/2. Example I got a response from topic/1, I want to freeze topic/2 and unfreeze topic/1 without losing the changes in the working directory and keeping the commit tree clean

What would be the correct way to approach this workflow?

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

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

发布评论

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

评论(1

一场信仰旅途 2025-01-23 11:28:45

git stash 应该做你想做的。它存储您当前所做的任何更改,而无需推进您的分支。

git stash

稍后,当您返回分支并想要恢复工作目录中的文件时。

git stash pop

如果您进行了多次存储,则需要小心地恢复哪一个,但您可以在 git 文档

git stash should do what you want. It stores any changes that you currently have, without advancing your branch.

git stash

Later when you get back to you branch and want to restore the files in your working directory.

git stash pop

If you do multiple stashes you need to be a little careful which one you restore but you can find more information on that in the git doc

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