如何将所有修改移动到分支

时间:2010-04-01 06:45:24

标签: git mercurial

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

如何将我的所有修改移动到分支(我尚未创建的分支)? (有点'git stash'和移动存储会改变到分支。实际上,我不知道我怎么能在git中做到这一点。如果你知道,我很感激,如果你能用Git告诉我的话) / p>

谢谢。

2 个答案:

答案 0 :(得分:4)

对于Git,如果您还没有提交文件,只需输入:

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

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

对于Mercurial,默认情况下,分支不是名称,如果提交的父级已经有子级提交,则只会出现一个新分支(在一个repo中):

enter image description here

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

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"

(另请参阅Guide to branching in MercurialGit & Mercurial models

答案 1 :(得分:2)

首先检查以确保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合并。

相关问题