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

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.

Related

Setting up git on wordpress: Issue with git add

I have been trying to setup git on a WordPress site, The issue seems to be that while I run git add --all.
The files get deleted for some reason. Not sure what seems to be the issue.

How to install WordPress on Heroku?

I want to build wordpress on Heroku as the following article:
WordPress on Heroku: Up and Running!
Here’s the step by step tutorial for getting a WordPress.org installation running on Heroku’s Cedar stack:
Create GitHub repo
Then create local repo with GitHub as the upstream for origin. Basically like it says on the new repo page:
cd REPO-NAME
# Create the readme file... use your favorite editor.
# Put in something informative
mate README.markdown
git add .
git remote add origin git#github.com:brookr/REPO-NAME.git
git push -u origin master
I have downloaded Cygwin, installed Git.
I have created the GitHub repo according to https://help.github.com/articles/create-a-repo
mate README.markdown doesn't work.
How can I do this?
As mentioned in the article you linked, mate is simply an example text editor:
mate README.markdown # Create the readme file... use your favorite editor. Put in something informative
In this case it's the command-line interface to Textmate, which is only available on OSX.
You could use Sublime Text, Emacs, Vim, Notepad++, almost anything. Even Notepad might work, though its Windows-only line endings might muss things up.
As Cupcake mentions in the comments, the Git commands in the tutorial will need some tweaking as well. git add stages changes, which then get committed with git commit. git push pushes committed changes, so if you don't git commit you won't be pushing anything.
There may be other minor bugs in the article as well, though it looks reasonably close to what you want.
The repo on github is empty. There is nothing to clone.
The "git clone REMOTE LOCAL" makes/names the local dir. So your next command should have been "cd 99catfacts.com" had the remote existed to be cloned.
How can I do this?
https://devcenter.heroku.com/categories/php
It's beta, but that is better than; clone this, hit moving target x, have WP site.

Update Wordpress when using Github Wordpress skeleton

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.

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.

Git checkout for submodules not working for WordPress

I have WordPress as a git submodule and it is checked out at tag 3.8.1.
I want to get the latest version of WordPress which is 3.8.2.
I have done the following structure:
/html
/wp - submodule to WordPress
I then run the following commands:
$ cd wp
$ git checkout 3.8.2
Previous HEAD position was 22bb602... Tag 3.8.1
HEAD is now at 5577e02... Tag 3.8.2
However when I go and check the WordPress dashboard it still tells me that I still need to update to 3.8.2.
3.8.2 is actually a tag, not a branch. It points to a specific commit. Pulling makes no sense there.
If you want to stay up-to-date with the 3.8 version use the branch 3.8-branch.
$ git checkout 3.8-branch
$ git pull
This was a complete red herring. The git checkout 3.8.2 was working. But I hadn't properly checked the file changes and there's no such indication that the files have been updated as when you do a git pull.
However the WordPress dashboard was thinking that I was not on the latest version because I am using a dutch translated version of WordPress.
So in the wp-config.php I have define( 'WPLANG', 'nl_NL' );
This then requires that you are using the nl-NL installation of WordPress from e.g. https://downloads.wordpress.org/release/nl_NL/wordpress-3.8.2.zip
However because I am using the github version of WordPress, that only has the US English version of WordPress. Its a hack, but to fix the problem I just edited the wp-includes/version.php file, to include the following line at the bottom, which is the only file that differs in the WordPress core for the translated version:
$wp_local_package = 'nl_NL';
Then WordPress is happy that you have the latest version.
Then you have to pull in the translation files.

Resources