I have created a new project locally and it is a template application that has some base code (for upcoming projects), and I pushed it to a remote repository on Github. And all is working fine.
I am trying to create new projects (with their own local and remote repositories) out of that template app. For example, say the current project is called TemplateApp. I want to build a new project (based on TemplateApp) but is called CoffeeMaker (name should both be locally called and remotely). How can I do that?
I tried cloning TemplateApp, then renaming the project locally (and all its files - which is FRUSTRATING) and then do git init
and finally push to a new repository. IF this works, I have not succeeded yet as I kept failing in renaming the project locally.
When creating the new branch, you could choose to preserve the previous history or not. Suppose to create new
from the latest master
in TemplateApp:
#enter the local TemplateApp
cd TemplateApp
#preserve the history
git checkout -b new master
#don't preserve the history
git checkout --orphan new master
git commit -m 'init'
#modify the files
git add .
git commit -m 'changes for CoffeeMaker'
#push the new branch to TemplateApp
git push https://github.com/xxx/CoffeeMaker.git -f new:refs/heads/master
#or
git remote add coffee https://github.com/xxx/CoffeeMaker.git
git push coffee -f new:refs/heads/master
Now the new repository is created with a master
branch. You and others can now clone and work:
git clone https://github.com/xxx/CoffeeMaker.git