AndroidGit

Git divide one project into two

2020-10-29  本文已影响0人  JaedenKil

Scenario:
I have an instrument test project, on master branch containing four tests.
Try to add two test: Create a new branch dev, add two tests.
Then later, we decide these two tests should be seperated into a new project

Solution:

  1. Push currrent dev branch to remote
  2. cd and mkdir, create a new folder(Not directly clone since there is already one existing project directory)
  3. In the new folder, execute:
git clone --single-branch --branch=dev repoUrl

Now I have a new project containing only this specific branch dev

  1. Rename dev to master:
git branch -m dev master
  1. Create a new remote repository, and push master to the new repository
// Since this project is cloned from remote to local, there is already an existing remote repo
git remote set-url origin newRepoUrl
git push origin master
  1. Rename project
上一篇下一篇

猜你喜欢

热点阅读