TheoG TheoG - 20 days ago 5
Git Question

Howto update multiple github projects generated from a single fork?

So I have a fork, which I use as a template for various projects.

When I update the fork (master) from the upstream, I then want to update each subsequent project.

A. At the moment I follow the following steps for each new project:


  1. Create new github project and clone to disk

  2. Clone fork to disk

  3. Delete contents from the new project folder, and copy across contents from the cloned fork

  4. npm install (new project)



B. When the fork is updated


  1. backup project src files, then delete project contents

  2. copy across updated fork contents o project folder, and reinstate project src files

  3. npm install (project)



Is there a more effective way to resolve updating each project from the updated fork?

Answer

Creating new project

  1. Create new repository on Github. Do not clone
  2. Clone fork with remote named upstream into folder with new project name

    git clone -o upstream https://github.com/<user>/<fork>.git <my_new_project_name>
    
  3. Add new repository url remote

    cd <my_new_project_name>
    git remote add origin https://github.com/<user>/<my_new_project_name>.git
    git push origin master
    
  4. npm install

Updating

git pull upstream master