X

Headline

This is an important message requiring you to make a choice if you're based in the EU.

Learn Git

Git is a free and open-source version control system that is widely used in the programming world. It is used for tracking changes in the source code during software development. It was developed in 2005 by Linus Torvalds, the creator of the Linux operating system kernel. Git is an efficient distributed VCS tool that can handle projects from small to very large ones providing cheap local branching, convenient staging areas, and multiple workflows. It is considered to be the most preferred VSC tool providing more effective results for developers. Git enables multiple developers or software teams to work separately without having an impact on the work of others. By the end of the book, you will learn all the needed Git commands and workflows.

The book covers the following chapters:

Getting started

In this section, you will learn all about version control system, source code management for managing source code, and version control software for a collaborative software team workflow. You will get an overall introduction about what is Git, how to install Git on different operating systems and have a full understanding of Git repository. This section will also provide information about SHH key (Secure Shell network protocol) for secure login.

Setting up a repository

In this chapter, you will learn how to set up a Git repository and initialize it for a new or an existing project. The points of this chapter will cover everything about generating a new Git repository or initializing an existing one, copying it into a new directory, configuring a Git repository for remote collaboration, and creating short commands that map to longer ones. The commands are described below. Find detailed information about the following commands on our next pages. The git init, git clone, git config and git alias commands are introduced at high level.

Saving changes

In this section, you will examine the concept of committing. The git add, git commit, git diff, git stash, and .gitignore commands will teach you the right way of adding changes in the working directory to the staging area, saving all currently staged changes of the project, comparing changes committed in Git, shelving changes you have made to your working copy, and specifying untracked files to ignore.

Examining a repository

In this chapter, you will learn how to examine Git repository with the help of git status, git log, git tag, git blame. The section will cover everything related to the state of the working directory and the staging area, references displaying particular points in Git history, display of author metadata attached to the specific committed lines, and the committed snapshots. The commands needed for examining Git repository are presented in detail.

Undoing changes

Git has its own “undo” system with completely different terminology, which includes such terms like git clean, git rm, git reset and git revert. Each command has its specific functions and is used for undoing changes on the local and public repositories.

Rewriting history

Git has different mechanisms for rewriting history, which include the git commit --amend, git rebase and git reflog commands. In this chapter, you will examine the changing of the last commit, the record of updates that are made to the tip of branches, the combination of commits to an entirely new base commit.

Syncing

Git gives the opportunities to share branches between repositories instead of sharing a single changeset. In this chapter, you will learn about the set of commands that have their responsibilities in the syncing process. The git remote, git fetch, git push, git pull commands participate in the “syncing” process.

Using branches

Branching allows developers to branch out from the original code base and work separately. This section of the book will teach you the basics of creating, switching, merging and deleting branches. It will also provide tools to solve merge conflicts and multiple strategies to choose while merging. You will have an overall understanding about the git branch, git checkout, git merge commands. Also, you will examine merge conflicts and find out merge strategies best suited for your project.