Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git workflow - using one repo as the basis for another

Tags:

git

github

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?

like image 452
Skilldrick Avatar asked Nov 04 '10 12:11

Skilldrick


People also ask

Can Git be used in a centralized workflow?

Centralized Git workflowA centralized Git workflow enables all team members to make changes directly to the main branch, with every change logged in a running history. A centralized workflow involves every contributor committing to the main branch without using any other branch.

Does Git allows centralized multiple repositories to work together during software development?

Because Git allows you to have multiple remote repositories, it's possible to have a workflow where each developer has write access to their own public repository and read access to everyone else's. This scenario often includes a canonical repository that represents the “official” project.

What is forking in Git?

Forking is a git clone operation executed on a server copy of a projects repo. A Forking Workflow is often used in conjunction with a Git hosting service like Bitbucket. A high-level example of a Forking Workflow is: You want to contribute to an open source library hosted at bitbucket.org/userA/open-project.


1 Answers

First, clone the skeleton repository:

git clone ssh://[email protected]/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://[email protected]/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).

like image 96
vhallac Avatar answered Oct 13 '22 01:10

vhallac