Tools & Tips

Using Git (via GitBash) for Version Control

Whether you’re working on content or code, version control is the best way to stay sane. Being able to edit your work knowing that any mistakes or problems can be rolled back is reassuring – and also an essential part of a professional content writer or coder’s workflow.

It can all sound super-nerdy, but using Git is surprisingly simple. I’ve been using GitBash, which really helped to demystify the process. There are only a handful of commands required. After a small amount of setup (setting your Environment Variables, for example) you’ll be ready to go.

Here’s a quick reference to all the git commands you need.

To create a new git repository:

  1. Navigate to the directory containing your files (for WP dev can navigate straight to the directory for your theme: don’t waste time and space adding the whole wp-content folder as most of the time you won’t touch it.)
  2. Type git init.
  3. Type git add -A to add all the files in that directory – or use the specific file or folder name, if you just want to add a subset of the directory contents.
  4. Type git commit – and you’re done.

If you make a mistake and need to remove any files (as I’ve just accidentally done):

  • Type git rm -r [file-name.txt], where file-name.txt is the file or folder to remove.

After making updates:

  • Type git commit -m “[commit message]” to commit your changes.

That’s it!

For a full list of commands, there’s this handy list on github.

Are you using git to track your project’s changes? If not, why not!?

Leave a Reply

Your email address will not be published. Required fields are marked *