Git: The Popular Version-Control System

8th September 2019

Having a version-control (or source-control) system has become essential in the world of Software Development. It allows you to track changes from any user, meaning you can see who changed what.

Similarly, it allows you to branch off work. This is very important if you are developing a large part of the system that will not be launched for sometime. Branching off work means that your changes won't be reflected in any releases until you're ready.

And merging has become a great tool that comes with version-control systems. When you merge your branch into another branch, the system will try and do it automatically with the existing changes. If it's unable to do it, it will notify you to do it manually.

In a international industry, you could be working with someone half way around the world. Source-control allows you to share your project in one place that everyone connects to.

Which one to choose?

To answer this question, we need to find which version-control systems exist. The two main systems you have are Git and Apache Subversion (or SVN).

Having used both of these systems in the past, I can tell you that the main difference between the two is that Git allows you to perform local tasks on your machine before you send it to the server. With SVN, all tasks are performed on a centralised server.

That can have it's advantages and disadvantages on both sides. With Git, you don't need to do any additional setup to use, which would be an advantage if you are working alone. Similarly though, if you have a larger team and don't send your commits to the server regularly, your repository could get out of date very quickly. This is less of a case with SVN.

But, my preferred option is Git, as there are many free hosting services out there. These include the ever popular GitHub, and BitBucket. I would recommend using one of these services so your changes are available in an external location. Very handy if something happens to your machine!

Some of the Tools of Git

Now, I could go through and list all the different commands that are available in Git. But GitHub have created an excellent cheatsheet which you should keep for future reference.

But here are some of the Git commands that I use on a regular basis:

  • Init - This allows you to create a new repository on your machine. This is useful if you are creating project from scratch
  • Clone - This downloads a project from a centralised server and all it's project history. It's important to note that this server could be anywhere in the world.
  • Pull - If you have a project that is connected to a centralised server, you can pull down the latest changes
  • Push - If you are ready to make your changes available to the centralised server, this command allows you to do this
  • Branch - As mentioned above, this is useful for large enhancements. You can branch off into a new repository and commit to that repository. This avoids interference with the production repository.
  • Merge - This allows you to merge a branch into another branch. An example of this is merging a large enhancement into the production repository.

Git Software

Some people prefer to use Git using the command line. However, there are many UI interfaces that help you with your Git system. These include GitKraken and SourceTree.

These tools allows you to perform Git tasks without having to remember command lines. It also gives you a nice graphical history of all the changes, in which branch, and which user has made the change.

Here is an example from GitKraken:

GitKraken History UI

Conclusion

Regardless of the size of your project, or how many people you have working on your project, there is no reason why you shouldn't be using a version-control system. It allows you to view all your changes, branch off larger pieces of work and view all the push history. And with Git, you don't even have to have a centralised server.

It's also worth noting that version-control systems can work very well with DevOps, allowing the process of automated deployment just by pushing a change to your repository.

It's something I would recommend to all software developers.

About the author

David Grace

David Grace

Senior .NET web developer | ASP.NET Core | C# | Software developer

Free .NET videos

  • Do you want to watch free videos featuring .NET 7 new features?
  • How about what's new in C# 11?
  • Or a recap on the SOLID principles?
Watch our .NET videos