+44 0330 223 3428
Call Us
+44 0330 223 3428

WPTavern: A Very Brief Introduction to Version Control and Git

WPTavern: A Very Brief Introduction to Version Control and Git

This post was contributed by guest author Peter Suhm. Peter is a web developer from the Land of the Danes. He is the creator of WP Pusher and a huge travel addict, bringing his work along with him as he goes.
 


Have you ever done this?

Most of us have.

Do you know what the technical term for it is? Version control. Your own, homemade, delicious implementation of version control!

Okay, how about this?

Version control right there!

What I’m trying to show with these two examples is that all developers use some sort of version control. Some use Ctrl-z to roll back to a previous version, some use a zipped backup in a Dropbox folder and some use a dedicated version control system (VCS), such as Git. All the things we are trying to accomplish by backing up our files, commenting out old code and stashing it away in another “final-FINAL” zipball has been taken care of already. All we need to do is to embrace these VCS tools that we have available in our tool belt.

Git is not complicated to use. It might seem difficult and overwhelming but in your day to day life you will probably use a maximum of 3-4 different commands. Learning how to use 3-4 commands to properly have version control of every single change ever made to your code base is a great deal compared to the “final-FINAL” approach.

Here’s what version control looks like:

This is a screenshot of the WordPress Git mirror on GitHub. Every time a change is made to the code base, it is recorded with Git and there is no need to copy the whole code base, throwing it into another folder, zipping it and naming it “final-FINAL-F-I-N-A-L”. If you dive into the WordPress code base on GitHub, you can find commits dating back to 2003, made by “someone” named saxmatt!

Let’s dive into one of these commits, as they are called in Git:

This is the diff (Git jargon for difference between 2 commits) for the “class-wp-widget-text.php” file. The red line is being replaced with the green line below it. No need to comment it out to save it for eternity, like in that other example. Git will do that for us and we can forever and always refer back to this commit to see what was replaced and with what.

Of course, the full WordPress code base is a large project with many collaborators. However, no project is too small to benefit from Git. Once you master those 3-4 commands, using Git in your day-to-day developer life becomes second nature, just like hitting Ctrl-s. It might not be obvious right now, but when you pull out an old project months or years later, having version control helps you catch up and gives you the confidence to change things without fearing disaster.

So I challenge you to learn Git! Not necessarily deeply, just a little bit.



Source: WordPress

Related Post
WPTavern: AMP Plugin for WordPress 1.1 Adds Experimental PWA Plugin Integration, Pre-release of AMP Stories Editor Available in 1.2-alpha

WPTavern: AMP Plugin for WordPress 1.1 Adds Experimental PWA Plugin Integration, Pre-release of AMP Stories Editor Available in 1.2-alpha Version 1.1 of the AMP Plugin for WordPress was released this week after four months in development and 125 merged pull requests from contributors. It includes CSS tree shaking improvements that restore AMP compatibility for WordPress’ […]

Read more
Post Status: “Become the best version of yourself.” An Interview with Rich Tabor

Post Status: “Become the best version of yourself.” An Interview with Rich Tabor Rich Tabor is transitioning to a new role now as Senior Product Manager of WordPress Experience with GoDaddy. In the past three years, Rich founded a digital agency, launched a popular PhotoShop resource site, and started ThemeBeans, a successful WordPress theme shop. […]

Read more
WPTavern: WordPress 5.2 Will Add 13 New Icons to the Dashicon Library

WPTavern: WordPress 5.2 Will Add 13 New Icons to the Dashicon Library Dashicons, the WordPress admin icon font, will be getting its first update in three years when WordPress 5.2 ships. The library will be updated to use WOFF2 (Web Open Font Format 2), replacing the previous WOFF 1.0 format for improved compression. WOFF 1.0 […]

Read more