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

后端 未结 5 2482
悲&欢浪女
悲&欢浪女 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:02

    The goal is to keep everything updated with any underscores update, while changing and modifying the framework and the themes

    That is called the triangular workflow:

    • fork (see "Fork a Repo") the repo automattic/_s
    • clone that fork locally,

      git clone /url/my/fork myfork
      
    • add as remote upstream the original repo

      cd myfork
      git remote add upstream https://github.com/automattic/_s
      

    From there, with git 2.9 or more, configure:

    git config --global pull.rebase true
    git config --global rebase.autoStash true
    

    Finally, each time you want to update your branches (where you modify your own version of the original repo), do a

    git checkout mybranch
    git fetch upstream
    git rebase upstream/master
    

    Then you can merge that updated branch (after testing it) to your other repos my_theme1, my_theme2, cloned from myfork.

    cd my_theme1
    git fetch
    git merge origin/mybranch
    

    If you want to work locally only, you can skip the fork step and clone directly the original repo.

提交回复
热议问题