我正在使用 Git 流程,我从一个开发分支开始,主分支。后来,创建了一个从develop分支出来的功能分支,当功能完成后,我将它合并回develop。下一次,我没有创建新的功能分支,而是创建了一个新分支并在其上添加了提交。目前,我使用的是 Origin/Mybranchname 而不是 develop/my-feature-branch。如何使我当前的分支转换为从开发分支出来的功能分支?
1 回答
You need to rename your branch so it follows the convention of feature branches, and then to rebase your branch onto the develop branch.
To rename your current branch, check out your branch and use git branch -m
:
git checkout my-branch-name
git branch -m feature/my-branch-name
Once your feature branch has been appropriately renamed, you can proceed with the rebase. Make sure you have the latest origin/develop
changes using git fetch
, and then rebase your feature branch onto origin/develop
using git rebase
:
git fetch
git rebase origin/develop
Depending on whether your changes overlap with the ones that have been done on origin/develop
, you may have merge conflicts. You can fix these conflicts similarly to the ones you may have had in the past with git merge
.