如何将所有修改移至分支

发布于 2024-08-27 00:07:35 字数 164 浏览 5 评论 0原文

我在 HG 中创建了一个工作存储库。 而且我修改了一些文件。

如何将所有修改移至分支(我尚未创建的分支)? (类似于“git stash”,并将存储的内容移至分支。实际上,我也不知道如何在 git 中做到这一点。如果你知道,如果你也能在 git 中告诉我,我将不胜感激)

谢谢你。

I create a working repository in HG.
And I have modified some files.

How can i move my all my modification to a branch (a branch that I have not created)?
(kind of 'git stash' and the move the stash away change to a branch. Actually, I am not sure how I can do that in git either. If you know, I appreciate if you can tell me in git as well)

Thank you.

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

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

发布评论

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

评论(2

别挽留 2024-09-03 00:07:35

对于 Git,如果您尚未提交文件,只需键入:

$ git checkout -b newbranch
$ git commit -m "a message"

此时暂存的每个文件都将在新分支中提交。

对于 Mercurial,默认情况下分支不是名称,并且仅当提交的父级已有子提交时才会出现新分支(在一个存储库内):

在此处输入图像描述

但您可以创建一个新的分支名称对于您的下一次提交:(

hg branch branch-1          # start a new branch name
                            # modify something in the repository
hg commit -m "branch-1"     # the changeset has branch name "branch-1"

另请参阅 指南Mercurial 中的分支,以及 Git 和 Mercurial 模型)

For Git, if you have not yet committed your files, just type:

$ git checkout -b newbranch
$ git commit -m "a message"

Every file staged at this point will be committed in the new branch.

For Mercurial, branches are not names by default, and a new branch only occurs (within one repo) if a commit has a parent which has already a child commit:

enter image description here

But you can create a new branch name for your next commit:

hg branch branch-1          # start a new branch name
                            # modify something in the repository
hg commit -m "branch-1"     # the changeset has branch name "branch-1"

(See also a Guide to branching in Mercurial, and Git & Mercurial models)

败给现实 2024-09-03 00:07:35

首先检查以确保 ShelveExtensionAtticExtension 完全按照您的意愿行事。

如果您在 Mercurial 中手动执行此操作,我会避免使用命名分支,而只使用另一个头。例如,如果您已经做出了想要“暂时搁置”的更改。

hg commit -m 'working on Xxx' # you created a new tip
hg update -r -2               # switch to the revision before the tip

现在就开始在那里工作吧。您可以稍后使用 hg Heads 找到该匿名分支,并使用 hg merge 将其合并。

First check to make sure that neither the ShelveExtension nor AtticExtension do exactly what you want.

If you're doing it manually in mercurial I'd avoid a named branch, and just use another head. If for example, you already made the changes you want to "put away" for a little bit.

hg commit -m 'working on Xxx' # you created a new tip
hg update -r -2               # switch to the revision before the tip

and now just start working there. You can find that anonymous branch later with hg heads and merge it in with hg merge.

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