What is the proper git workflow for basing a project off a 'seed' repo?

后端 未结 5 615
渐次进展
渐次进展 2020-12-25 14:03

As an example: suppose you have a personal project like Angular Seed (which is a starting point for an Angular project https://github.com/angular/angular-seed).

Now

相关标签:
5条回答
  • 2020-12-25 14:37

    I found mirroring the boilerplate according to this article the only way to work for me:

    Clone boilerplate and create new project:

    git clone --mirror https://github.com/mxstbr/react-boilerplate.git
    cd react-boilerplate.git
    git remote set-url --push origin https://github.com/gitUser/newProject
    

    Update the new project with changes from the boilerplate:

    cd react-boilerplate.git
    git fetch -p origin
    git push --mirror
    
    0 讨论(0)
  • 2020-12-25 14:38

    Option 1: clone / fetch / merge

    Clone the master branch of the seed project of your choice, for example:

    $ git clone -o react-starter-kit -b master --single-branch \
          https://github.com/kriasoft/react-starter-kit.git MyApp
    $ cd MyApp
    

    Down the road, you can pull and merge updates from the seed project back into your local repo by running:

    $ git checkout master
    $ git fetch react-starter-kit
    $ git merge react-starter-kit/master
    $ npm install
    

    Option 2: clone / pull / diff

    Clone the seed project and remove its version history:

    $ git clone https://github.com/kriasoft/react-starter-kit --depth=1
    $ git clone https://github.com/kriasoft/react-starter-kit MyApp --depth=1
    $ cd MyApp
    $ rm -rf .git
    

    Then, whenever you need to pull the latest updates from the seed project back into your local repo, you can navigate to the original seed project, pull the updates (git pull), then compare that folder with your project's folder by using some good Diff tool (e.g. Beyond Compare) that allows you to save and customize folder comparison sessions.

    0 讨论(0)
  • 2020-12-25 14:53

    I just found this answer https://stackoverflow.com/a/4096529/131227 as well as a comment (git workflow - using one repo as the basis for another) which together lead me to a solution I like.

    git clone -o boilerplate ssh://git@github.com/user/proj.git new_proj
    The -o boilerplate renames the origin to boilerplate which can still be used to pull changes from.

    Create your new empty github new_proj repo. Then
    git remote add origin ssh://git@github.com/user/new_proj.git

    0 讨论(0)
  • 2020-12-25 14:58

    I think the right answer here is to use something like Yeoman Generators. (http://yeoman.io/) You want to use the git repo with your seed project as a generator. It wouldn't allow you to continually pull in changes from the seed project though.

    The solution of using two remotes works, but eventually the projects will diverge enough that will make keeping those projects in synch very difficult.

    0 讨论(0)
  • 2020-12-25 15:03

    What you could do is:

    • initialize a new repo
    • reference your angular repo as a submodule of that new repo
    • push that new repo in your GitHub space.

    That way, your new project has:

    • a subfolder representing your seed project (which you don't modify)
    • all your data specific to your project.

    My issue with that is that a seed project isn't a library. It doesn't live in a subdirectory of a project. It IS the project when you start, and you build from there.

    Then a simple clone that you push back to your new repo is enough.
    But that won't keep any "fork" relationship between your two GitHub repos.
    You will have to pull one and push to the other through a local clone.

    0 讨论(0)
提交回复
热议问题