2017-07-04 4 views
0

私はGitプロジェクトにプロジェクトブランチとマスターブランチを持っています。プロジェクトブランチをマスターブランチにしたいと思います。しかし、私は古い枝を側枝にしておきたいと思います。これどうやってするの?Gitスイッチマスターとプロジェクトブランチ

電流:私が欲しいもの

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

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

チェックこのリンクします。https:// stackoverflowの

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 

今すぐあなたの分岐構造は、次のようになります.com/questions/2763006/make-the-current-git-branch-a-master-branch – 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. 

EDIT:それが公共のレポであれば、これをしないでください!

0

あなただけの以下の方法により取引所に二つの枝のためのブランチ名を必要とする:

-------------------- project (new master branch) 
    \______ master (old) 
関連する問題