I use Git when working on my WordPress projects.

On occasion, when I’m working on the latest branch and testing out some changes, styling, code etc, I’m *really* excited that I’ve squashed that bug / made that visual improvement.
However, it’s only then that I realize I didn’t create a new branch for my current round of changes.

So, it’s copy/paste, multiple CTRL-Z’s and then paste in. But wait! The changes are in multiple files. Darn.

Have no fear. Git can help.

At the command line:

git stash
git stash branch new-fix-feature-branch-name-you-should-have-created-in-the-first-place

Git stashes the original changes, then creates and checks out the new branch name I provide and places me in the new branch *and* applies the changes.

The changes that were stashed and then applied to the new branch are also removed from the “stash pile” by design and upon successful application.

And Voila! Sanity replaces profanity.

Categories: WordPress

1 Comment

Version control with WordPress - Sean Hayes - professional WordPress consulting · August 3, 2018 at 5:54 pm

[…] as part of a team. Or even try and cover the many ways you can use Git, some Git tips (like this Git Stash tip) or Git tools in a development workflow whether you are a developer or a business owner looking to […]

Leave a Reply

Avatar placeholder