Create local git repository based on local repository based on github repository and keep it updated
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 myforkgit remote add upstream https://github.com/automattic/_s
From there, with git 2.9 or more, configure:
git config --global pull.rebase truegit 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 mybranchgit fetch upstreamgit 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_theme1git fetchgit merge origin/mybranch
If you want to work locally only, you can skip the fork step and clone directly the original repo.
you should learn about child themes. the concept of it is having a main theme - which gets updated - and a child theme that'll you'll modify, add content, create different templates & styles... everything to your needs.
I'd recommend taking some minutes to read this throughtfully: https://codex.wordpress.org/Child_Themes
Assuming you using a terminal,cd to the themes directory:
cd [PROJECT]/wp-content/themes
Now clone _s to your project:
git clone git@github.com:Automattic/_s.git [THENE-NAME]
After the clone ends you can start working with your new theme.cd to theme directory:
cd [THENE-NAME]
and create another remote for your repo.
git remote add [NEW-RENOTE-NAME] [NEW-RENOTE-URL]
From now on, you can push change into your private remote:
git push [NEW-RENOTE-NAME] master
and if you want to get updates from _s repo you can just:
git pull origin master
Good Luck!