git工作流程 - 使用一个回购作为另一回购的基础 [英] git workflow - using one repo as the basis for another

查看:154
本文介绍了git工作流程 - 使用一个回购作为另一回购的基础的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我分叉了 Paul Irish github 上的HTML5样板,因此我可以拥有自己的版本,更适合我的需求。如果我用这个样板启动每个新的Web项目,那么将代码转换为新回购的最佳方式是什么?据我所见,我有两个选择:克隆回购。




  • 克隆回购。我不只是想克隆它,因为我没有真正对样板进行更改 - 我只是将它作为新网站的启动点。此外,如果我从github克隆,那么样板库将设置为新站点的远程站点。

  • 复制粘贴代码到一个新目录并在那里开始一个新的git回购。这种感觉是错误的。




有没有更好的方法来处理这个问题?
<解决方案首先,克隆骨架库:

  git clone ssh ://git@github.com/user/proj.git new_proj 

然后,cd到回购站,并摆脱远程源:

  cd new_repo 
git remote rm origin

最后,为该项目创建一个新的远程控制器(您可能希望首先在github中创建一个新项目):

  git remote add origin ssh://git@github.com/user/new_proj.git 

现在,当您执行 git push origin master 时,它应该更新新项目。你仍然会有原始项目的历史。事实上,你可以将初始的起源重命名为 projbase 或者其他的一些,你甚至可以选择你的骨架的变化(尽管这可能会使合并方面有点混乱,而且一旦你推到github上,rebase就会被压低)。

I've forked the Paul Irish's HTML5 boilerplate on github so I can have my own version which better suits my needs. If I start every new web project with this boilerplate, what's the best way to get that code into a new repo? As far as I can see I've got two options:

  • Clone the repo. I don't just want to clone it, because I'm not really making changes to the boilerplate - I'm just using it as a launching-off point for a new website. Also, if I clone from github then the boilerplate repo will be setup as my remote for the new site.

  • Copy-paste the code into a new directory and start a fresh git repo there. This feels wrong somehow.

Is there a better way to handle this?

解决方案

First, clone the skeleton repository:

git clone ssh://git@github.com/user/proj.git new_proj

Then, cd to the repo, and get rid of the origin remote:

cd new_repo
git remote rm origin

And finally, create a new remote for the project (you may want to create a new project in github first):

git remote add origin ssh://git@github.com/user/new_proj.git

Now, when you do git push origin master, it should update the new project. You will still have the history of the original project. In fact, you can rename the initial origin to projbase or some such, you can even pick up changes to your skeleton (though that could make things a bit messy in terms of merges, and rebases are frowned upon once you push to github).

这篇关于git工作流程 - 使用一个回购作为另一回购的基础的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆