Git should be treated as a tool that makes your life as a developer easier and allows you to try new ideas without risking the integrity of your code base. Use of git, or any other source control tool, should not be treated as unnecessary paperwork or an afterthought. Use git for everything you do such that it becomes second nature. The mastery of git is a skill that all developers should attain.

This training is meant to be a hands on, exercise based introduction to git. git is a source code management tool that is widely used in the IT industry.

This document will not cover the following:

  • Using git on Windows (although command line git via bash works).

  • Using git from a GUI tool or from an IDE as I believe mastery of git on the command line is far more powerful and portable than what most GUI tools can provide (the may be some GUI tools out that are quite powerful, I don’t use GUI tools, other than gitk, so I probably speak from ignorance here).


  • Create an empty local git repo.

  • Make changes within your local repo.

  • Working with branches in your local repo.

  • Clone a remote repo.

  • Publish your changes to a remote repo.

  • Fetch/Merge/Pull changes from a remote repo.

  • Collaborate with other developers.

  • Select and negate commits using git-revert and git-cherry-pick.

The Pro Git Book

Much of the information for this document came directly from the Pro Git Book.

Reading this book from cover to cover and understanding it all will put you well on the way to becoming an expert git user.

Before going any further with this document, you are strongly encouraged to read the following chapters of the Pro Git Book:

If you do that, you may not need this document, but it is hoped that this document will be a good companion to the book.

Also recommended reading after you have mastered the basics:

Reference links to the Pro Git Book are provided when relevant throughout this document.

Contributing to the Document

This is an open source document with the source project hosted on gitlab

Feel free to use the issue tracker there to report problems or to request improvements to the document. Please include the version string, shown at the top and bottom of each page of the html, in the issue so that we can better determine how to address the issue.

If you want to help improve the document, please fork it and send merge requests.

Viewing the Document

This automatically generated html is viewable:

A PDF version of the document is available for download:

These are automatically updated when changes are pushed to the master branch of the source project.


This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

Creative Commons License


There are a few things you need to do to prepare for the training.

  • Install git tools on your system.

    • git

    • gitk

    • a diff tool (kdiff3, meld, xxdiff, etc)

    • others???

  • Create a user account on gitlab, github, or bitbucket (or any git hosting service you want to use; your company might host a service internally that you can use to collaborate with your co-workers).