This tutorial will give you a practical guide to using the Git tool for version control, so you can easily managing changes to source code and configuration files in projects. The tutorial also covers collaborating on projects using Github public repositories.
If you just want a very quick start, take a look at Git in two minutes.
Please read an overview of Git if you want more background into the tool and how distributed version control works.
- Checking the status - what has changed – git status, git diff
- Staging changes - basic add, git add -p, unstaging untracked files, unstaging tracked files, git diff –cached
- Committing a new version
- try out code and modifications to design, different algorithms
- easily discard changes that are not needed - or leave them in a branch so they are not affecting / poluting the main codebase
- Collaborating with Github
- Practices to avoid when using shared repos like Github
- rebasing, forgetting to push changes (especially for sub modules)
- what to do if you loose your head
- if you really have to change a commit
- unstage changes
- Git submodules
You can quickly get versioning your code with Git, all on your own computer. You do not need to set up a server.
To give you a big picture view of how you use Git and Github, here is a visualisation of the workflow for both. The details of this workflow are ocvered in the workshop from Chapter 10: Collaborating with Github onwards.
- Git commands cheat sheet
- Git Visual cheat sheet
- StarLogs.net demo with this workshop
- Github repository for this workshop - pull requests welcome :)
Stuff to look at
git reflog – lists all the commits that you ever did
git bisect – binary search on your git history
git bisect good
git bisect bad
git bisect reset
This work is licensed under a Creative Commons Attribution 4.0 ShareAlike License, including custom images & stylesheets. Permissions beyond the scope of this license may be available at @jr0cket