Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
The Linux DevOps Handbook

You're reading from  The Linux DevOps Handbook

Product type Book
Published in Nov 2023
Publisher Packt
ISBN-13 9781803245669
Pages 428 pages
Edition 1st Edition
Languages
Concepts
Authors (2):
Damian Wojsław Damian Wojsław
Profile icon Damian Wojsław
Grzegorz Adamowicz Grzegorz Adamowicz
Profile icon Grzegorz Adamowicz
View More author details

Table of Contents (20) Chapters

Preface 1. Part 1: Linux Basics
2. Chapter 1: Choosing the Right Linux Distribution 3. Chapter 2: Command-Line Basics 4. Chapter 3: Intermediate Linux 5. Chapter 4: Automating with Shell Scripts 6. Part 2: Your Day-to-Day DevOps Tools
7. Chapter 5: Managing Services in Linux 8. Chapter 6: Networking in Linux 9. Chapter 7: Git, Your Doorway to DevOps 10. Chapter 8: Docker Basics 11. Chapter 9: A Deep Dive into Docker 12. Part 3: DevOps Cloud Toolkit
13. Chapter 10: Monitoring, Tracing, and Distributed Logging 14. Chapter 11: Using Ansible for Configuration as Code 15. Chapter 12: Leveraging Infrastructure as Code 16. Chapter 13: CI/CD with Terraform, GitHub, and Atlantis 17. Chapter 14: Avoiding Pitfalls in DevOps 18. Index 19. Other Books You May Enjoy

Git, Your Doorway to DevOps

Git is a free and open source version control system (VCS) that is widely used by software developers and teams to track changes to their code base and collaborate on projects. It allows multiple people to work on the same code base without overwriting each other’s changes, and it keeps a record of every change made to the code, making it easy to roll back to a previous version if necessary.

Git was created by Linus Torvalds in 2005 for the development of the Linux kernel, and it has since become the de facto standard for version control in the software industry. It is used by millions of developers worldwide and is supported by a large and active open source community.

In this chapter, we will cover the most commonly used Git commands and how to use them. We will start with the basics of setting up a Git repository and making your first commit, and then move on to more advanced topics such as branching and merging.

The chapter will cover...

Technical requirements

In this chapter, you will need a system with a Bash shell. You will have to have the Git command available or be able to install it in this system. We prefer Linux or macOS systems, but it is possible to set up Windows to have functional Bash and Git. The installation of this environment is beyond the scope of this book.

Basic Git commands

There are many commands that you can use with Git, but some of the most commonly used ones include the following:

  • git config: This is the command used to configure your local Git environment. The configuration can be global; the values will then be kept in your home directory in the .gitconfig file. The values can only be set per repository, and then they will be kept within the repository.
  • git init: This initializes a new Git repository. When you run this command in a directory, it creates a new .git directory in the root of the project, which is used to track changes made to the project’s files.
  • git clone: This creates a local copy of a remote Git repository. When you run this command, it creates a new directory with the same name as the repository and clones all of the files and their history into that directory.
  • git add: This stages files for commit. When you make changes to a file in a Git repository, those changes are not automatically...

Local versus remote Git repositories

In Git, a repository is a collection of files and their history, as well as configuration files that are used to manage the repository. A repository can be either local or remote.

A local repository is a repository that is stored on your local machine. When you initialize a new Git repository using the git init command or when you clone an existing repository using the git clone command, you are creating a local repository. Local repositories are useful for working on projects when you don’t have an internet connection or when you want to keep a copy of the project on your own machine.

A remote repository is a repository that is stored on a server and accessed over the internet. When you push commits to a remote repository using the git push command, you are updating the remote repository with your local changes. Remote repositories are useful for collaborating with other developers, as they allow multiple people to work on the same...

GitFlow and GitHub Flow

GitFlow is a branching model for Git, created by Vincent Driessen. It aims to provide a consistent and easy-to-use branching model for teams working on software projects. The GitFlow model uses two main branches: develop and master. The develop branch is used to develop new features, while the master branch represents the current production-ready state of the code base. There are also several supporting branches, such as feature, release, and hotfix, which are used to manage the process of developing, releasing, and maintaining software.

GitHub Flow is a model that was developed by and for GitHub for use with its hosting and collaboration platform. It is similar to GitFlow, but it is designed to be simpler and easier to use, especially for smaller teams and projects. In the GitHub Flow model, all development is done in branches, and new features are merged into the master branch using pull requests. There is no separate develop branch, and the master branch...

Summary

Git is such a powerful tool that it’s hard to fit all its features into a single book. In this chapter, we’ve learned the most basic tasks you will need to know in your day-to-day work as a DevOps engineer, and you are well equipped to handle most of the issues you will encounter.

In the next chapter, we will focus on Docker and containerization, where we will put all the skills you’ve gained so far to the test.

lock icon The rest of the chapter is locked
You have been reading a chapter from
The Linux DevOps Handbook
Published in: Nov 2023 Publisher: Packt ISBN-13: 9781803245669
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}