+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: Gutenberg 3.3 Released, Adds Archives and Recent Comments Blocks

WPTavern: Gutenberg 3.3 Released, Adds Archives and Recent Comments Blocks Gutenberg 3.3 is available and continues the trend of refining the user experience, user interface, and tools. Two new Widget blocks have been added, Post Archives and Recent Comments. Archive and Recent Comments Widget Blocks If your archives span across multiple months and years, you […]

Read more
WPTavern: Karachi to Host First WordCamp in Pakistan Following Cancellation of WordCamp Lahore

WPTavern: Karachi to Host First WordCamp in Pakistan Following Cancellation of WordCamp Lahore photo credit: Bilalhassan88 WordCamp Karachi is happening on August 4, 2018, and organizers are expecting more than 400 attendees. Karachi is the largest city in Pakistan with a population of more than 30 million people. Its airport connects the country to other […]

Read more
Post Status: Why the makers of Ninja Forms are getting into eCommerce

Post Status: Why the makers of Ninja Forms are getting into eCommerce Welcome to the Post Status Draft podcast, which you can find on iTunes, Google Play, Stitcher, and via RSS for your favorite podcatcher. Post Status Draft is hosted by Brian Krogsgard and co-host Brian Richards. In this episode, I bring on James Laws […]

Read more