Reader small image

You're reading from  The Linux DevOps Handbook

Product typeBook
Published inNov 2023
PublisherPackt
ISBN-139781803245669
Edition1st Edition
Concepts
Right arrow
Authors (2):
Damian Wojsław
Damian Wojsław
author image
Damian Wojsław

Damian Wojsław has been working in the IT industry since 2001. He specializes in administration and troubleshooting of Linux servers. Being a system operator and support engineer he has found DevOps philosophy a natural evolution of the way sysops work with developers and other members of the software team.
Read more about Damian Wojsław

Grzegorz Adamowicz
Grzegorz Adamowicz
author image
Grzegorz Adamowicz

Grzegorz Adamowicz has been working in the IT industry since 2006 in a number of positions, including Systems Administrator, Backend Developer (PHP, Python), Systems Architect and Site Reliability Engineer. Professionally was focused on building tools and automations inside projects he is involved in. He's also engaged with the professional community by organizing events like conferences and workshops. Grzegorz worked in many industries including Oil & Gas, Hotel, Fintech, DeFI, Automotive, Space and many more.
Read more about Grzegorz Adamowicz

View More author details
Right arrow

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 2023Publisher: PacktISBN-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.
undefined
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

Authors (2)

author image
Damian Wojsław

Damian Wojsław has been working in the IT industry since 2001. He specializes in administration and troubleshooting of Linux servers. Being a system operator and support engineer he has found DevOps philosophy a natural evolution of the way sysops work with developers and other members of the software team.
Read more about Damian Wojsław

author image
Grzegorz Adamowicz

Grzegorz Adamowicz has been working in the IT industry since 2006 in a number of positions, including Systems Administrator, Backend Developer (PHP, Python), Systems Architect and Site Reliability Engineer. Professionally was focused on building tools and automations inside projects he is involved in. He's also engaged with the professional community by organizing events like conferences and workshops. Grzegorz worked in many industries including Oil & Gas, Hotel, Fintech, DeFI, Automotive, Space and many more.
Read more about Grzegorz Adamowicz