如何提交对新分支的更改

我只是修改了一个分支。 我的问题是,我如何将更改提交给其他分支?

我正在尝试使用:

git checkout "the commmit to the changed branch" -b "the other branch"

但是,我不认为这是正确的,因为在这种情况下,我创建了一个新分支,而不是将更改提交给“其他分支”。

我应该使用下面的命令吗?

git merge "the other branch"

谢谢。


git checkout -b your-new-branch

git add <files>

git commit -m <message>

首先,检查你的新分支。 然后添加您想要提交到分段的所有文件。 最后,提交您刚刚添加的所有文件。 之后你可能想要做一个git push origin your-new-branch ,这样你的更改就会显示在远程。


如果我理解正确,那么您已经对changed_branch进行了提交,并且您想将该提交复制到other_branch ? 简单:

git checkout other_branch
git cherry-pick changed_branch

你可以使用隐藏你的工作,创建一个新的分支,然后弹出你的隐藏更改:

git stash
git checkout -b branch_name
git stash pop

这将会像创建新分支后做出这些更改一样。

链接地址: http://www.djcxy.com/p/23591.html

上一篇: how to commit changes to new branch

下一篇: Git create branch from current checked out master?