美文网首页AndroidGit
Git divide one project into two

Git divide one project into two

作者: JaedenKil | 来源:发表于2020-10-29 17:26 被阅读0次

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
  • In android studio, open this new project
  • In android studio top left, choose Project
  • In app/src/androidTest/java/${projectName}, right click, choose Refactor - Rename
  • In the new warning dialog, choose Rename Project
  • File - Invalidate Caches / Restart
  • In app - build.gradle, update applicationId

相关文章

网友评论

    本文标题:Git divide one project into two

    本文链接:https://www.haomeiwen.com/subject/hsikvktx.html