Chapter 6. Unleash the Beast – Git on Text-based Files

We have seen two different modes of working with our content managed by Git in earlier chapters, with a gaming analogy calling it the single/solo player mode and multiplayer mode.

Hold on to your seats. This chapter is an answer to your long awaited question: What about the real multiplayer mode with several people playing in parallel? In other words, having multiple people work on the same stuff at the same time.

The concepts that we are going to learn about in this chapter are as follows:

  • Merging and
  • Resolving conflicts, making your way through the content in the way you or your team want to

Git for text-based files – an introduction

Git arms itself with several functionalities when it comes to handling text files. On a higher level let's understand the different file types and what they really mean using the following stack:

Git for text-based files – an introduction

Going from the top to the bottom, it is a layered approach starting with how a user sees a file, how a computer sees it, until its storage at the bottommost layer.

Note

Binary data: Any file whose contents can be read only through specific programs, such as Microsoft Word for documents and picture viewer for images, is called binary data/values.

Text data: Any file, irrespective of its extension or nature, whose content is pure text and can be opened with a normal text editor like notepad or WordPad is considered to contain text data.

To quote an example for giving more clarity, open up your .git directory inside your project, and you will see a file structure as shown in the following screenshot:

Git for text-based files – an introduction

Here the file called index is considered to contain binary data whereas the files COMMIT_EDITMSG, config, description, and HEAD are considered to have textual data. Open them with your text editor and you'll understand why.

Note

Make sure you don't alter anything in those files or else you might end up with a screwed up version of your repository, which might need a few maneuvers to fix, which we are not interested in at the moment.

As another example, you can also try opening an image file with a text editor to view its raw content.

This is the basic difference that we were talking about. Let's talk more about it once we have understood the concept of branching and merging.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.27.178