Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 2

Best way to make master branch as non-master

At beginning I develop my program with mysql version as a branch master. Next I save it as version before_hbase. Next I develop master with Hbase and mysql and branch before_hbase.

Now Hbase version is abandoned. I want make MapR version from before_hbase as a fork.

How do these:

- change before_hbase to name : mysql

- change old master to name: hbase

- new MapR will master

alternative (better?):

- change before_hbase to name : master

- change old master to name: hbase

- new MapR will mapr

 

How preserve history with gitk view?

 

1 Reply
Moderator
Message 2 of 2

Re: Best way to make master branch as non-master

As long as you have some branch pointing to the point or points in history that you want to preserve, you don't have to worry about losing information. That is one of the awesome things about Git. And even if you mess up, the information is still in your repository, but it is harder to re-establish a branch when you don't have a pointer.

 

It sounds like what you want is:

 

  1. Branch before_hbase to become master
  2. Branch master to become hbase
  3. Branch MapR to become mapr

 

If my above understanding is correct, then this is what I would recommend. Warning: while none of these actions are destructive, making changes of this type might make it hard to recover from if something goes wrong. Therefore, I strongly recommend having a backup of your Git repository (not just the files inside it) somewhere else while you're making these changes.

 

From the root of your repository:

 

 

git checkout master
git checkout -b hbase
git branch -D master
git checkout before_hbase
git checkout -b master
git checkout MapR
git checkout -b mapr

 

And then you're done!

 

Notice, the only branch we deleted was the original master and that was only after we had created hbase to point to it. Because Git branches are simply pointers to a point in the Git history graph, we can mostly just create new branches and not worry about deleting the old ones until we're sure we don't need them anymore. The only one we needed to delete was the one whose name we wanted to reuse 😀

 

I hope that helps!