Create local git repository based on local repository based on github repository and keep it updated

后端 未结 5 2455
悲&欢浪女
悲&欢浪女 2021-02-20 11:42

I have some basic git knowledge but I\'m not sure how to accomplish this.

I am trying to clone (?) github WordPress starter theme underscores. The idea is to create a ba

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-20 12:21

    What you want to do is called nested git repo. GitHub does not allow nested repositories. You can use GitSubmodule or subtree. It is done for when projects become bigger.

    One copy of underscores will remain as "control". Second copy of underscores will remain is starting of my_framework. Third copy is copied and modification of my_framework.

    You can :

    1. Update underscores repo aka WordPress starter theme underscore master separately
    2. Change in your framework separately
    3. Send pull request for wherever you want to contribute

    my_theme1, my_theme2 are not versions but separate softwares. my_theme1 as example can have nth versions. Here are sample steps :

    cd ~ 
    mkdir parentrepo 
    cd parentrepo/ 
    git init . 
    mkdir child1 
    mkdir child2 
    cd child1/ 
    git init . 
    echo "FirstChildRepo content" > child1repofile.txt 
    git add . 
    git commit -a -m "Adding FirstChildRepo content" 
    cd ../child2/ 
    echo "SecondChildRepo content" > child2file.txt 
    cd .. 
    echo "parentrepofile" > parentFile.txt 
    git add . 
    git commit -a -m "Adding Parent Repo content" 
    # verify whether working independently 
    cd ~/parentrepo/ 
    git log 
    cd ~/parentrepo/Child1Repo/ 
    git log 
    # try cloning parent, verify the contents
    cd ~ 
    git clone parentrepo/ 
    cd parentrepo/ 
    ls -a 
    ./  ../  .git/  child1/  child2/  parentfile.txt 
    cd child1/ 
    ls -a 
    ./  ../ 
    

    Work after this step to clone, update in the way whatever like others written.

    You can "auto update" too. Add files named post-checkout & post-merge to .git/hooks directory of the needed repositories and add this into each of them:

    #!/bin/sh
    git submodule update --init --recursive
    

提交回复
热议问题