In the previous chapter, we looked at the core concepts of modern DevOps, had an introduction to the cloud, and got a fair understanding of containers. In this chapter, we will understand source code management and one of the modern ways of enabling DevOps with GitOps.
In this chapter, we’re going to cover the following main topics:
- What is source code management?
- A crash course on Git
- What is GitOps?
- The principles of GitOps
- Why GitOps?
- Branching strategies and GitOps workflow
- Git versus GitOps
Technical requirements
To follow this chapter, you will need access to a Linux-based command line. If you are using macOS, you can use the inbuilt Terminal for all tasks. If you’re a Windows user, you must install GitBash from https://git-scm.com/download/win. We will cover the installation instructions for this in the following sections.
Now, let’s start by understanding source code management.
What is source code management?
Software development involves writing code. Code is the only tangible aspect of the software, allowing the software to function. Therefore, you need to store code somewhere to write and make changes to existing software. There are two kinds of code – source code, which is written in a high-level language, and binaries, which are compiled from the source code. Generally, binaries are nothing but functional applications that execute when we run the software, and source code is the human-readable code written to generate the binary, which is why source code is named as such.
A software development team has multiple members writing software features, so they must collaborate on code. They cannot just write code on silos without understanding how the application works. Sometimes, more than one developer works on the same feature, so they need some place to share their code with their peers. Source code is an asset in itself; therefore, we want to store it securely in a central location while still readily providing access to developers without hampering their work. You will also want to track changes and version them as you might want to know what caused a problem and immediately roll them back. You will also need to persist the history of code to understand what changes were made by whom, and you will want to have a mechanism for source code peer reviews.
As you can see, you would want to manage multiple aspects of source code, and therefore you would use a source code management tool to do so.
A source code management tool helps you manage all aspects of source code. It provides a central location to store your code, version changes and allows multiple developers to collaborate on the same source code. It also keeps a record of all changes through a version history and everything else that we’ve talked about before. Effective source code management practices improve collaboration; enable efficient development workflows; provide version control, repository management, branching and merging, change tracking, and auditing; and enhance the overall quality and maintainability of software projects. Some popular SCM tools are Git, Subversion, Mercurial, and CVS. However, the most popular and de facto standard for SCM is Git. So, let’s go ahead and learn about it in the next section.