This article lists some excellent tutorials to learn Git / Github, along with some practical advice for the same. Git is the most popular Version Control System, which is used by nearly all major software projects now. Learning git will help you pick up any version control system easily, teach you to make larger projects effectively as well as contribute to massive open source projects (as long as you have the relevant programming experience).
Two Important Clarifications
Before we begin, two important clarifications. Git is not the same as Github. Also, Git is NOT a programming language.
- Git is not the same as Github - Git is a version control tool, which is generally distributed in systems as a command line utility or less frequently as a GUI. Git will work on your project code locally, and will help you collaborate with others. Git doesn't really store your code, it is a tool. Github on the other hand is a web service which is used to store different versions (by different people) of many projects. Github makes use of Git, and provides a GUI to compare code across it's server, merge code, review code and a lot of excellent software development tools (most of what's described in Software Development) to help you out.
- Git is NOT a programming language - It is more like a software toolkit, which has got a few tricks and procedures that you must understand properly if you wish to use it correctly. It's easy to master the basics, and also very easy to go wrong. (Terribly wrong, deleting your month's work. We've seen it happen).
None, quite really. It's better if you know a programming language and have a few projects though, as that will give you an excellent chance to learn the workflows by pushing real code to Github rather than test repositories. Also, several concepts will be easier to understand with real code in front of you. You must install Git, and it's recommended to have a Linux distribution. (Windows will work too, using Git Bash)
Version control (also known as source control) is the management of file changes within a version control system. These systems automatically maintain character level changes for all files stored within allowing for a complete retrace of all versions of each file, the author of those versions, and a complete rollback of all changes from the beginning of version control.
For developer-oriented work, it is critical to utilise version control systems for all non-binary files (read Notepad readable) to enable multiple developers or teams to work in an isolated fashion without impacting the work of others. This isolation enables features to be built, tested, integrated, or even scrapped in a controllable, transparent, and, maintainable manner.
The basics of version control is the ability to save changes made to files, whilst retaining the changes from all previous versions. All changes made within Git receive a unique version identifier alongside a user written comment where the changes can be described.
Changes to file are monitored at the character level. When changes are made in a developers local work space they are committed (saved locally) and, then pushed (sent to the repository) within Git, this makes them available for consumption by other developers in the team. Those developers pull (fetch new updates from the repository) all the changes to their own local work space. This flow allows developers to work on a range of features within a project without impacting the work of others. Once they have completed their feature, it is pushed to the repository and made available to others.
Branching within Git is a way of taking a copy of the code into what's called a branch. This allows the developers to isolate all their changes within that branch before merging (applying the changes to the main copy of the code) once the feature that has been worked on is complete. Multiple developers can work on a branch simultaneously.
Branches should always be used when making changes to existing code. Those changes should never be done directly on the main copy of the code as the changes (when incomplete) will break the code impacting other developers.
Implementing Git within a workplace might seem daunting as there is a myriad ways of organising a repository around your workflow. Gitflow is a universal branching solution that can be implemented (and even comes inbuilt in Sourcetree, my personal Git application of choice) in order to simply and formalise the correct usage of branching in Git.
The basics of Gitflow is as follows:
- The production version of your code sits in a branch named
- The development version of your code (ready to be tested and productionised) sits in a branch named
- When development on a new feature is started, a new branch is created off of the
developbranch. This is a
- When development has completed, the feature branch is either merged back into the
developbranch if the changes are to be taken into production, or left in their respective branch if they are not.
- When the code in the
developbranch is finally ready to be released into production, a new
releasebranch is created.
- When the
releasebranch is approved for release, it is merged into the
developbranch to capture any fixes that may have been done directly on the
- If a defect is found within production that requires a quick fix (not running through the normal release lifecycle of develop, test, integrate) a
hotfixbranch can be created off the
hotfixbranch will be worked on to develop the fix to the defect. After development has concluded, the
hotfixbranch is merged into the
developbranch (to ensure the fix is applied in the lower branches where it doesn’t exist yet).
Where Should I Begin?
Unfortunately, git is complicated and it might take sometime to master. But it's really important that you do try to master it, since it's so important in today's software development. The most important thing is that you actually upload some real projects to Github. Just reading tutorials and concepts will not teach you much. Here are some good starting points -
- Git Tutorial - This is a very basic tutorial made by us, it's a good place to start with Git. Do have a look and feel free to contribute.
- [Slides] Git Introduction - A little short of examples, but should be good to get you started. Built out of our personal experience with Git.
- Git It - An excellent series of real tasks to learn Git / Github, by the Github staff member Jessica Lord. Scroll down to view the README file.
- Git Cheat Sheet - A huge list of git commands and tricks
- Git Parable - A story behind the workflow of git.
- git-scm - The official documentation of Git. A very well documented resource.