Update Wordpress when using Github Wordpress skeleton - wordpress

This is mainly a clarification about dealing with public Repos for git beginners.
I have a local git repo with a clone of Wordpress skeleton (https://github.com/markjaquith/WordPress-Skeleton). This includes Wordpress as a submodule (https://github.com/WordPress/WordPress).
If I update Wordpress from the dashboard it will require me to update my git repo.
There is a note about making a pull request if the repo falls behind but I am working on my localhost so can't do that.
If I had a hosted repo, should I send a pull request to the WP skeleton or WP repo?
I have a fresh install at the moment but if I were to customise it I probably wont want to (or Shouldn't) push so what would I do in this case?
Note: This is using the Wordpress repo as an example but I am curious about the best/general practice.

I'm having some similar questions, mainly about what the best practice is when updating Wordpress. Should I use the Dashboard once on remote, or should I continue to update the Wordpress Submodule in WP-Skeleton.
I can tell you this, you can update Wordpress via the Submodule in WP-Skeleton by using the "Git Checkout" command on the submodule and choosing the latest release number (4.1 as of this writing). Its extremely simple in SourceTree if you're new to Git and need an interface to help.

This is a little late but I asked the author of the repo and he answered me in his QA repo on Github.
This is the answer Mark Jaquith gave there which worked:
For your personal sites, which have likely wildly diverged, the update
process is as follows:
cd wp
git fetch
git fetch --tags
git checkout 3.9.1
cd ../
git add wp
git commit -m 'Update to WordPress 3.9.1'
git push origin master
Let me break that down:
cd wp — move into the WordPress submodule directory.
git fetch — Pull down the latest changes from tracked branches.
git fetch --tags — Pull down the new tags. You do steps 2 and 3 in this order because otherwise you might have a tag that points to a commit that you don't yet have in your repo.
git checkout 3.9.1 — Checkout the 3.9.1 tag.
cd ../ — Move back into the main directory. At this point, the wp subdirectory will show as having changes, since it points to a different commit.
git add wp — Tell your main repo to stage the WordPress submodule repointing.
git commit -m 'Update to WordPress 3.9.1' — Commit that change git push origin master — Push your master branch (change if using a different branch) up to your origin remote (change if using a different remote).
You probably noticed that there
is only one variable here — the version number. So You could wrap that
up into a bash script that you check into your root directory. And
then you could just do something like: ./wpupdate 3.9.1. Or you could
write a script that iterates through a bunch of WordPress site
checkouts and does this process on each of them (I've done exactly
that).
I will also add that from the wp folder you can enter git tag to see a list of tags, this way you can make sure you get the latest one.

Related

WordPress as git submodule, accidentally updated through WP admin instead of git, now modified content

I followed David Winter's workflow to "Install and Manage WordPress with Git." WordPress is a git submodule. On the latest WordPress 3.9 upgrade, I accidentally updated through the WordPress admin instead of via git. Now when I run git status I get:
modified: wordpress (modified content, untracked content)
Which makes sense. But I can't commit the modified wordpress content. The WordPress submodule is dirty. If I run git diff within my main repo, I get this:
-Subproject commit 22bb60277036651db73dc872eaa7d2a50276b00d
+Subproject commit 22bb60277036651db73dc872eaa7d2a50276b00d-dirty
What's the best way to fix this? If I run the following within my main repo, will it mess up my WordPress install? (Note: I had also updated some plugins.)
git clean -dfx # delete everything in the worktree that isn't tracked
git reset --hard # wipe all modifications to tracked files
git checkout 3.8.1 # return to previous version tag
Update: The commands above work perfectly. I checked the documentation on git clean to learn what the options 'd', 'f', and 'x' were: https://www.kernel.org/pub/software/scm/git/docs/git-clean.html. After I ran the previous commands within the WordPress directory, I was able to then checkout version 3.9, thus correctly updating WordPress.
The following commands worked perfectly:
git clean -dfx # delete everything in the worktree that isn't tracked
git reset --hard # wipe all modifications to tracked files
git checkout 3.8.1 # return to previous version tag
I checked the documentation on git clean to learn what the options 'd', 'f', and 'x' were: https://www.kernel.org/pub/software/scm/git/docs/git-clean.html. After I ran the previous commands within the WordPress directory, I was able to then checkout version 3.9, thus correctly updating WordPress.

How do I git out of this mess with a git submodule?

I've got a git repo with Wordpress as a submodule. I was trying to update Wordpress and really screwed things up. I just want to get all of the code from the 3.7.1 tag in the remote repository, but this doesn't work;
git fetch --tags
git checkout 3.7.1
Leaves a bunch of either "untracked files" or "uncommitted changes". I don't know what I'm doing wrong. I've tried so many things to get this submodule onto the 3.7.1 tag and nothing seems to work. If anything, I feel like I'm just making the problem worse. It shouldn't be that hard to just reset the code from the tag I want and discard everything else. Any help?
Here's the git nuclear option:
git clean -dfx # delete everything in the worktree that isn't tracked
git reset --hard # wipe all modifications to tracked files
git checkout 3.7.1
which looks appropriate here.

Setting up Git repo with other Git repo with Submodule? (WordPress development)

I have a Git project/repo called "ABC" to which I would like to add WordPress among other things.
ABC
WordPress
Other
Stuff
Ideally I would like to base my WordPress setup on the WordPress Skeleton repo.
(The WordPress Skeleton also contains a submodule referring to the latest stable WordPress release.)
How do I go about creating this setup?
Should I fork the WordPress-skeleton vs copy it into my existing repo?
How do I update the submodule that the WP-skeleton refers to from my ABC git repo?
I guess I am confused regarding the use of forks in this scenario when I want the ABC to contain code from other repos that in themselves have submodules.
Basically what you are looking for is a tool to manage multiple repos. Here are few:
repo (http://source.android.com/source/version-control.html)
gitslave (http://gitslave.sourceforge.net/)
Also beware of submodule gotchas':
http://codingkilledthecat.wordpress.com/2012/04/28/why-your-company-shouldnt-use-git-submodules/
#dani I did something like that. I created this git project: http://stechico.github.io/wordpress-skeleton/
Code samples there if any. HTH

How to Upgrade and Deploy WordPress Install as a Git Submodule?

I am using a WordPress directory struture similar to Mark Jaquith's WordPress Skeleton, which has WordPress in a separate directory from the content as a submodule:
/content
/wp
/local-config.php
/wp-config.php
/index.php
I also use git and post-receive hooks to push my code changes up to my live server. It all works great except for when I try to upgrade WordPress and push that up to the live server.
This is how I setup the repo on my local machine and the remote server:
Local Machine
cd /www
git init .
git submodule add git://github.com/WordPress/WordPress.git wp
git commit -m "Add Wordpress submodule."
cd wp
git checkout 3.5
After checking out the tag, I get a warning from git about being in a 'detached HEAD' state. Since I don't plan on making any commits to WordPress, I don't think that should be an issue.
cd ..
git commit -am "Checkout Wordpress 3.5"
Remote Server
git init --bare
cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/home/public git checkout -f
chmod +x hooks/post-receive
git remote add web ssh://user#server/home/private/code/wordpress.git
git push web +master:refs/heads/master
I get this error:
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'ssh://userserver/home/private/code/wordpress.git'
After some googling, it looks like I can use this command to sync up the master branch up to the server (I have no idea how this works)
git push web +master:refs/heads/master
This doesn't help me though because I don't want to track master, I want to track a release tag, 3.5. Some more googling got me to this command:
git push web +3.5~0:refs/heads/master
To upgrade the submodule, I do this:
cd wp
git fetch && git fetch --tags
git checkout 3.5.1
git push web +3.5.1~0:refs/heads/master
Am I doing this correctly? All the tutorials I see for this just have git push web and they're done. Most don't even cover upgrading the submodule. This does work but I don't feel comfortable using this weird push syntax if I don't have to.
How do I push this detached HEAD state up to the server correctly?
I've also tried this using a branch with git checkout -b mywp 3.5 but when it comes time to upgrade, I don't know how to bring in the new 3.5.1 tag into my mywp branch.
Asked this on WP Answers, but it might be more appropriate here.
On the remote server try:
git submodule update --init --recursive
This will update all your submodules recursively
You can also issue:
git fetch --tags
This will update your local tags fetching updated list from the central remote repo.

How to clone the latest stable branch to a dir via github?

I want to clone the latest stable version of WordPress from Github, via a shell script. It is simple to get the unstable master branch:
git clone git://github.com/WordPress/WordPress.git
But how can I get the highest numbered stable release via a script, not manually checking out the code. E.g., using deployment shell script or deployment tool such as Fabric.
Edit: I clarified the text to better indicate the intent that I meant how to do this from a script, not manually.
Clone from git and change to the WordPress directory
git clone git://github.com/WordPress/WordPress.git
cd WordPress
Then list out the branches..
git branch -r
This gives something like...
origin/1.5-branch
origin/2.0-branch
...
origin/3.4-branch
origin/HEAD -> origin/master
origin/master
Check out the branch you want...
git checkout 3.4-branch
Branch 3.4-branch set up to track remote branch 3.4-branch from origin.
Switched to a new branch '3.4-branch'
Here's what I actually ended up doing, which is included in a Fabric fabfile I have on Github:
git clone git://github.com/WordPress/WordPress.git .
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
It clones the repo like normal, then does some shell magic to find the latest tagged version of WordPress (Which is where the stable branches live.)
Can you try a git checkout master ?
git branch -r will show you all the remote branches
git checkout --track <local_branch> <remote>/<remote_branch> will setup a local branch that is tracking the remote branch in order to push or get new updates.
you can use this command after git clone
git checkout stable

Resources