我试图将整个分支重新绑定到主人身上。 Master通过几次新的提交通过了我的第一个分支提交。目前,我使用git reset HEAD~<X>
从整个分支创建1个提交,我取消分支我的分支,然后将其提交到单独的临时分支/存储它,然后在主服务器上重新绑定它。有没有更好的办法?
您有以下选择。从你的问题,我想你可能想要Merge + squash功能分支成为主选项,因为这将导致master
上的新提交,其中包含你在feature
分支上所做的所有更改,这似乎是你想要实现的,但是我也解释了其他选项,以防你喜欢另一种方法。
feature
branch into master
git checkout master
git merge feature
feature
branch into master
after incorporating master
branch changes into feature
branchgit checkout feature
git merge master
# Resolve merge conflicts if needed & git commit
git push
git checkout master
git merge feature
# Conflicts are not possible here,
# since they would have been already resolved in previous merge
git push
feature
branch into master
.这将在master
上创建一个新的提交,其中包含您从feature
分支合并的所有更改。缺点:feature
分支提交似乎不包含在master
分支中。
git checkout master
git merge --squash feature
git commit
git push
feature
branch on master
缺点:
feature
分支的所有提交都在master分支上重写。因此,feature
分支的提交将不会出现在master
分支中。feature
分支的所有提交在一行因此,请考虑上述选项之一。
git co master
git rebase feature
git push
feature
branch and then merge it into master
.缺点:你需要重写你的qazxsw poi分支的远程历史已被推送到远程。这通常是不可取的。有关详细信息,请参阅qazxsw poi