How to fork my own repo into a new project?

孤者浪人 提交于 2019-12-06 04:10:18

问题


I was developing an HTML5 game engine. I used Git as the SV and GitHub to actually host the project.

I've made some substantial changes in the design (mainly switching to the Entity System paradigm), and I think it's time for a new engine.

I would like to base it off the old engine, as there is a lot of code that I can use.

What would be the standard way of doing this? The new engine will have a new name, and the old one will be considered "finished".


回答1:


If you mean you want a new project with a new repo, but sharing history with the old one, then the simple way is

$ git clone https://github.com/your_name/old_project new_project
# make new, empty project on GitHub called new_project
$ cd new_project
$ git remote rename origin old_project
$ git remote add origin https://github.com/your_name/new_project
$ git push -u origin

Now you have a new project, but in your local clone you can still get commits from the old one to get bugfixes to common code with git cherry-pick etc.




回答2:


You need to branch

git branch <your_new_branch>
git checkout <your_new_branch>

to switch back to old branch

git checkout master

to list all branches

git branch


来源:https://stackoverflow.com/questions/11632566/how-to-fork-my-own-repo-into-a-new-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!