Table of contents
How To Read this document
This document wants to be a reference for best practices in the daily use of Git, despite the complexity of this tool it is worth mentioning that Git is a tool that tracks the changes in a repository (which is basically a directory containing a .git folder that has all the needed metadata to achieve file tracking).
Some concepts are stressed by the author for a simple reason: The main goal of Git is tracking the changes and years of experience have shown that Git is very good at that. However, this is not for free, it requires some attention by Individual Contributors (the engineers who commit changes, henceforth referred to as IC).
The history of a Git repository shows all the contributions and if ICs don’t follow some simple rules, it can easily turn into a mess, losing the primary goal: Tracking changes effectively.
Moreover, having a good history allows for some tasks, like understanding what happened, learning how to implement something and helping the reviewers with Pull Requests.
Git, like other tools, was designed to allow several ICs to work together efficiently.
This document is divided into items, which are designed to explain the pros and cons of every method.
To get the best out of this guide a little knowledge of command line tools is needed (also Git) so the reader, who is not proficient with those is strongly invited to read https://git-scm.com/book/en/v2 (especially the chapters 1. Getting Started, 2. Git Basics, and Git Branching).
Three categories are presented: Basic, intermediate and advanced, while the first two show safe practices the last one shows how to rewrite the history, which is forbidden when the branch is shared with other ICs but it can be safe when working alone (e. g. local branches).
... continue reading