2017-07-04 73 views
0

我在Git项目中有一个项目分支和一个主分支。我想让项目分支成为主分支。不过,我想保留旧的分行作为支行。我怎样才能做到这一点?Git开关主控和项目分支

电流:

----------- master 
    \______ project 

我想要什么:

-------------------- project (new master branch) 
    \______ master (old) 
+0

检查此链接https://开头计算器.COM /问题/ 2763006 /做出最电流的git分支 - 一个主分支 – LogicBlower

回答

1

如果你想交换分支机构的名称,可能是最简单的方法是:

git checkout --detach master # we put HEAD on master 
git branch -f master project # move master to project (HEAD doesn't move) 
git branch -f project # set project to HEAD 
git checkout project 
0
// If you want to still retain the old master branch, then create a tag or new branch on that particular commit so you don't loose it: 

git checkout master 

git checkout -b master-old 

// now if you want to go back to the old master branch you can checkout the master-old branch. 

// from here you can simply reset the master branch to the project branch 

git checkout master 

git reset --hard project 

git checkout master 

// now your master branch and the project branch should be pointing to the same commit. you can continue developing on your master branch. you may even want to delete the project branch. up to you. 

编辑:如果是公共回购,请不要这样做!

0

你只需要交流的分支名称通过以下方式两个分支:

git branch -m master project1 #change master branch name as project1 
git branch -m project master #change project branch name as master 
git branch -m project1 project #change project1 branch name as project 

现在您的分支结构看起来像:

-------------------- project (new master branch) 
    \______ master (old)