Reader small image

You're reading from  DevOps Unleashed with Git and GitHub

Product typeBook
Published inApr 2024
PublisherPackt
ISBN-139781835463710
Edition1st Edition
Tools
Concepts
Right arrow
Author (1)
Yuki Hattori
Yuki Hattori
author image
Yuki Hattori

Yuki Hattori, an architect at GitHub, showcases his hands-on expertise in DevOps and technical advice for enterprise clients. He began as a software engineer and progressed to cloud solution architect at Microsoft, overseeing cloud architecture and DevOps. A strong advocate for open source culture within an enterprise, he champions InnerSource adoption, serving as a board member of the InnerSource Commons Foundation. This nonprofit role drives global InnerSource adoption, breaking down organizational silos for innovation.
Read more about Yuki Hattori

Right arrow

Getting Started with Git

Let’s dive into learning Git. This chapter will touch upon the basic usage of Git. However, as explained in the previous chapter, this book is not just about introducing concepts and methods. It emphasizes communication and collaboration. Thus, while you will undoubtedly be able to master the basic usage of Git, you will also learn about the communication aspects behind it and how Git is used in team development.

In this chapter, we will first get a feel for the basics of Git by quickly going hands-on with the basics of file management and branching, and then we will cover how Git works. Then, you will get an understanding of the collaboration principles to be aware of when you are working with git as an engineer.

We will cover the following main topics in this chapter:

  • Getting started with Git
  • The anatomy of Git – A beginner-friendly explanation of how Git works
  • Becoming a guru of Git communication

Technical requirements

The configuration instructions for proceeding with this section can be found in the following GitHub repository link. Please make sure Git and ssh tools are installed. For Windows users, it is recommended to use PowerShell. I also encourage you to get the most up-to-date information written about the different commands and environments:

https://github.com/PacktPublishing/DevOps-Unleashed-with-Git-and-GitHub

Getting started with Git

In this section, we will proceed with how to use Git, assuming a scenario where you are working in an individual environment and simply building up a history.

Git basics – Begin with a hands-on experience

Before we delve into the details, let’s start with some hands-on experience. It is likely easier to grasp the concept by trying it out rather than just only reading about it at first.

git config – Introduce yourself to Git

Now, there is something you need to do before you start a project. Introduce yourself to Git. To introduce yourself to Git, use the git config command:

$ git config --global user.name "John Doe"
$ git config --global user.email "john@example.com"

git config is a command used to set Git configurations at the levels of system, user, and repository. The level system applies to all users and all repositories. The level global applies to all repositories of a specific user. The level local...

The anatomy of Git – A beginner-friendly explanation of how Git works

Git is incredibly powerful, especially as projects become more complex. Up until now, our focus was on a straightforward history. However, where Git really shines is in its ability to handle large projects with a large number of contributors and manage the dynamically evolving code within a team seamlessly. We have come this far intuitively, working with Git operations as commands work. It is time to get down to the nitty-gritty. While it is helpful to have an intuitive feel for Git, by understanding how Git operates behind the scenes, we can harness its full potential.

The file lifecycle in Git

In Git, we learned in the previous section that saving changes is a two-step action, staging and committing, but Git actually handles files in four states.

Every file in your project can be in one of four states:

  • Untracked: Files that are present in your directory but have not been added to Git’...

Becoming a guru of Git communication

Let’s hit the pause button for a moment. While most resources might hurry you along to cover essential Git commands, conflict resolutions, merge types, and Git workflows, we are taking a breather to focus on the core of the matter.

So, why was Git even developed in the first place? At its essence, Git was created to streamline communication in complex development projects. Since this book aims to elevate your role within a DevOps team, understanding the communicative power of Git is key. After all, DevOps is not just about technology; it is about improving collaboration, breaking down silos, and facilitating smoother workflows.

As you navigate through Git commands and repositories, bear in mind that you are not just sharing code; you are also communicating with your team. Your commits, pull requests, and merges should be thought of as dialogues in a broader conversation aimed at creating something magnificent.

So, as you proceed...

Summary

As you wrap up this chapter, you should feel more acquainted with Git’s essential features, underlying mechanics, and, most importantly, the philosophy of collaboration it champions. Understanding these fundamentals is often far more crucial than memorizing a litany of Git commands or stashing away snippets for quick use.

If you have internalized the insights from this chapter, rest assured you have obtained a solid grasp of Git’s basics. You are not just prepared to commit code; you are ready to be a collaborative force within your team.

When you first join a project managed by Git, the initial challenges are usually not resolving intricate conflicts or juggling chaotic branches; rather, the challenge lies in crafting meaningful commits and proving yourself to be an invaluable team player. Each well-considered commit you make not only contributes to the project but also fortifies your standing within the team.

Now, let’s move on to more advanced...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
DevOps Unleashed with Git and GitHub
Published in: Apr 2024Publisher: PacktISBN-13: 9781835463710
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

Author (1)

author image
Yuki Hattori

Yuki Hattori, an architect at GitHub, showcases his hands-on expertise in DevOps and technical advice for enterprise clients. He began as a software engineer and progressed to cloud solution architect at Microsoft, overseeing cloud architecture and DevOps. A strong advocate for open source culture within an enterprise, he champions InnerSource adoption, serving as a board member of the InnerSource Commons Foundation. This nonprofit role drives global InnerSource adoption, breaking down organizational silos for innovation.
Read more about Yuki Hattori