2016-05-16 152 views
0

我对使用Git没有太多经验。在我的情况下,我们有master分支,newversion分支和hotfix分支(这是从newversion分支)。如何将分支合并(或重新绑定)到github中的分支上?

现在,由于我检出了hotfix分支,因此在newversion分支上还有其他几个提交。我想在我的hotfix分支中“查看”这些更改,以便我可以使用可用的最新更改,以便获得最新更改和/或不重复相同的修复。

我看过this website,它解释了关于git rebase,但不幸的是它解释了合并主分支到分支,而不是从分支到分支。单词originmasterbranch让我困惑,而且我不确定如何修改网站上的以下示例以符合我的要求。

git checkout 7.x-1.x # Check out the "public" branch 
git pull    # Get the latest version from remote 
git checkout -b comment_broken_links_101026 # topical branch 
... # do stuff here.. Make commits.. test... 
git fetch origin  # Update your repository's origin/ branches from remote repo 
git rebase origin/7.x-1.x # Plop our commits on top of everybody else's 
git checkout 7.x-1.x # Switch to the local tracking branch 
git pull    # This won't result in a merge commit 
git rebase comment_broken_links_101026 # Pull those commits over to the "public" branch 
git push    # Push the public branch back up, with my stuff on the top 

我确定这只是一个简单的问题,我只是还不熟悉Git命令和术语。我通常使用Github Desktop,但我知道有一些事情需要终端,特别是对于像这样的特殊需求。请帮忙。谢谢。

回答

1

如果要合并newversion分支提交到hotfix分支,那么你需要以下步骤来做到......

git checkout hotfix 

git merge newversion 

的第一个命令将积极hotfix分支&第二个命令将合并所有最新提交从newversionhotfix分支。

:-)

+0

哦,看起来并不像我想的那么复杂。让我试试吧!谢谢! –

+0

这是为你工作吗? –

+1

对不起,是的,它工作!谢谢!! –

相关问题