如何将现有的分支名称重新用作新分支? [英] How do I reuse an existing branch name as a new branch?
问题描述
我的意图是拥有一个dev分支,我将创建功能分支.分支的那些功能将合并到dev分支中,然后将dev分支合并回master.我设法解决了一些问题,然后将开发分支留在了后面,所以这就是我现在拥有的.
My intent was to have a dev branch that I would create feature branches off. Those feature branched would be merged into the dev branch and the dev branch would then be merged back to master. Some how I managed to screw that up and I left my dev branch behind, so here is what I now have.
我认为在将password_rest_and_activation_support分支合并到master之后,我可以创建一个新的"dev"分支,称为"dev-new"或"development",但是我似乎应该能够以某种方式重用"dev"名称,但我不确定如何执行此操作.我当时只是想删除现有的dev分支并创建一个新的分支?考虑到dev分支也位于远程,什么是正确的方法?
I think after merging the password_rest_and_activation_support branch into master, I could just create a new "dev" branch, called "dev-new" or "development", but I seems like I should be able somehow reuse the "dev" name, but I am not sure how to do this. I was thinking of just deleting the existing dev branch and creating a new one? What the right way to do this, given that the dev branch is also on a remote?
推荐答案
git checkout master
git branch -D dev
(强制删除本地dev
)
git push origin :dev
(删除远程dev
)
git checkout -b dev
(创建一个新的本地dev
分支)
(create a new local dev
branch)
git push origin dev
(将新的dev
推入原点)
有关某些非破坏性选项(包括分支重命名),请参见 torek的答案 .
For some non-destructive options, including branch renaming, see torek's answer.
这篇关于如何将现有的分支名称重新用作新分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!