Git and Github Workshop

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.

Setting up Git & Github

Creating Git Projects

Local Git Workflow

  • 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
  • Git log

  • The local git workflow

Branching & Merging - why do this

  • 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 other developers using Git and Github

  • rebasing, forgetting to push changes (especially for sub modules)

Troubleshooting]

  • what to do if you loose your head
  • if you really have to change a commit
  • unstage changes

Resources

  • Git submodules

Git local workflow visualised

You can quickly get versioning your code with Git, all on your own computer. You do not need to set up a server.

Git and Github workflow visualised

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.

Reference

Back to top…

Things to look at

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

git hooks


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
Creative Commons License