简体   繁体   中英

How to clone a git bare repo and change branch names

I have a git repo on server, lets name it project.git

I'm in the process of separating part of the project into a separate, independent project and git repo (lets name that subproject.git).

I still want the subproject.git history to include the history in the origin project.git. So what I did to start this separation was to create a branch named subproject on project.git.

Now I want to create another bare repo (subproject.git) on the server, but make the subproject branch the master branch on this repo, and rename the original master branch as something else (ie: old-master)

I think I know how to do that on my local copy, but I'm not sure how to create the new bare repo to make it happen on the server.

Any suggestions ?

Think of it this way: the local and server copies are the same repository. Seems like you are still thinking of it the old C/S way.

I would recommend creating a new project, pulling in the existing one as a sub. (There are a lot of threads about that on here.) Then just push the whole mess.

Now, I know what you're thinking: my suggestion is going to mean you'll lose all your history. Nope.

Here's a thread on retaining history when making a project into a sub: How to Migrate Git Projects to Be One Project with Subprojects .

if i have to do i will probably do like this

i got this project called as "first-project.git"

  1. i will clone the project will call it "second-project.git"
  2. will create a new branch "future-master" in the local copy of second-project.git
  3. will do all my changes in local copy and do a commit and then follow this "how to delete master branch" link - How do I rename my git 'master' branch to 'release'?
  4. note : if you do not want to delete the master from second-project.git - just create a new branch of master and name it "old-master"

hope this helps !!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM