To subscribe to updates watch my GitHub repository. New posts get added as pull requests.

Learning Git

30 Oct 2015

I’ve found myself recently answering how to learn Git (or specifically how I learned Git). This post is for anybody who might be interested and it serves as a link of resources for myself.

I basically referred to the following educational resources starting out.

Learn the basics

Learning the basics by following the above instructions helps to prime you for moving on and learning about more advanced topics of Git. In order to understand any complicated problem or tool, if you don’t have the basics down then you’ll find it more difficult when tackling advanced topics.

Use it often

Use Git as often as you can. Any time you’re working with plain text files you should make use of Git as a habit. It’s real easy to simply:

git init
git add -A
git commit -m 'initial commit'

Then as you work on your project, regularly commit your changes by making use of git add and git commit.

Learn about workflows

Workflows are a simple concept of, “how do I work.” There are many strategies one can adopt when using Git. Any time you’re working in a semi-complicated project that involves either:

  1. Releasing software.
  2. Working with more than one person.

You should probably adopt a workflow for yourself. I tend to adopt workflow even for projects I work on by myself. When adopting a workflow it’s always best to adopt it through social agreement rather than putting in technical controls to force it. That is, everybody just informally agrees to adopt the workflow else be willing to be shamed for not adopting it. If you need technical controls around how a workflow is adopted, then there is software that can help. Gerrit, GitHub, and GitLab offer solutions to protect branches. Gerrit offers the most advanced access controls around forcing a particular workflow.

Here’s an interesting workflow of how the Pro Git book was written: Living the future of Technical Writing

Learn branching

Branches are nice for local and team development. They can be used for code review as part of a development workflow. It’s easy to branch off for an experiment and merge back if your proof of concept is valid.

Advanced Learning

Once you’ve learned the basics, workflows, and branching you might want to tackle more advanced topics when learning Git. I found these links to videos helpful and I also include a video I produced.

Reading documentation
  • Read the documentation first and search the Internet as a fallback.

It’s always better to read the man pages (i.e. manual pages) before attempting to search for it on the Internet. There’s several reasons to read the man pages before turning to the Internet. Some reasons include:

  • You become more familiar with the tool documentation.
  • You read the documentation which was explicitly written for the version of the tool in which you’re working.
  • Increase your own understanding of self-drafted solutions which can be succinct.

Occasionally, help you find on the Internet doesn’t work for the version of Git you’re working with. Primarily because the person providing the help is using options that aren’t available in your (likely older) version. Here’s some examples of how to read documentation from the terminal.

git help
git help push
git help clone

You can also access those same man pages using the man command and prefixing each help page with git-. For example,

man git-push
man git-clone

Nearly every command you could use with git has an associated man page. Take advantage of that! man is used to read manuals and apropose is used to search them. If you’ve not learned how to read man pages before then Internet search, “how to read man pages.”

I enjoy taking man pages and reading them on my ebook reader. I wrote a script which converts man pages to PDF for portable reading. Here’s a few examples of taking a Git manual page and converting it to PDF.

./man2pdf git-push
./man2pdf git-clone
./man2pdf git-config

Teach Git

By teaching Git to others you’ll find your own understanding is drastically improved. In order to explain to others, you must first comprehend yourself. The process of you comprehending and explaining improves your ability to work with Git to know the right solution on your own when you encounter problems.

Happy hacking!


This article was last updated Nov 20, 2017.

Posted in Education with tags: Git, Programming


Comments: