Course overview


  • Code along with the presenter.
  • Ask questions!

Why use a Version Control System?


  • Version control software refers to a type of program that records sets of changes made to files
  • VCS is a ubiquitous tool for software development
  • Tracking changes makes it easier to maintain neat and functional code
  • Tracking changes aids scientific reproducibility by providing a mechanism to recreate a particular state of your code base
  • VCS provides a viable mechanism for 100’s of people to work on the same set of files
  • VCS lets you undo mistakes and restore a code base to a previous working state
  • Git is the most widely used version control software
  • Using Git facilitates access to online tools for publication and collaboration

Committing and History


  • Setup Git with your details using git config --global user.name "FIRST_NAME LAST_NAME" and git config --global user.email "email@example.com"
  • A Git repository is the record of the history of a project and can be created with git init
  • Git records changes to files as commits
  • Git must be explicitly told which changes to include as part of commit (known as staging changes) with git stage [file]...
  • Staged changes can be stored in a commit with git commit -m "commit message"
  • You can check which files have been changed and/or staged with git status
  • You can see the full changes made to files with git diff for unstaged files and git diff --staged
  • The commit history of a repository can be checked with git log
  • The command git revert commit_ref creates a new commit which undoes the changes of the specified commit
  • The command git reset --soft HEAD^ removes the previous commit from the history

Break


Sharing your code


  • Public repositories are open to anyone to use and contribute.
  • Private repositories are just for yourself or a reduced set of contributors.
  • README contains a description of the software and, often, some simplified installation instructions.
  • The LICENSE describes how the software must be distributed and used.
  • Using one of the OSI (open source initiative) licenses is recommended if the repository is public.
  • CONTRIBUTING describes how other users can help develop the software.
  • CITATION helps others to cite your software in their own papers.
  • GitHub can be used to set up a software repository, share your code and manage who can access it, and how.

Remote repositories


  • origin is the default name used by Git to refer to a remote repository.
  • Local and remote repositories are not identical, in general, as synchronisation must be performed manually.
  • git fetch, followed by git status, shows whether there are any changes to synchronise.
  • git pull brings changes in the upstream branch to the local branch.
  • git push synchronises any committed changes in your local branch with the upstream branch.
  • push and pull commands only affect the branch currently checked out.

Break


Using GitHub Issues


  • Issues are a feature of GitHub which let you track work in a repository.
  • GitHub provides functionality for referencing issues in comments
  • Task lists can be created to keep track of a list of issues
  • Formatting syntaxes, templates, and subscribing to issues help with Communication

Using GUIs and IDEs


  • Knowing how to use Git from the command-line is useful for understanding concepts and as a fallback
  • Text editors and IDEs often have built-in Git support
  • GUIs are particularly useful for viewing the graph-like structure of a repository
  • It is worth taking time to explore other tools for Git so you can find a workflow that suits you.