# Computational Science Seminar ### A short introduction to version control with Git Will Usher, Tom Russell & Roald Lemmen --- # Agenda 1. intro 1. concepts 1. live coding 1. summary 1. next steps --- ## Resources These slides are available from: - https://nismod.github.io/presentations/a-short-intro-to-git.html Further resources are available from the website: - https://nismod.github.io/git-novice/ A list of commands used in the session is available for quick reference: - https://nismod.github.io/git-novice/commands/ --- ## Introduction * Given the limited time we can only give you a flavour of version control * This session will provide a bit of theory and a bit of practical demonstration * A more detailed practical will be scheduled for next term * Version control (and git in particular) has a steep learning curve – do ask for help getting started * There are many resources for self learning * Software Carpentry * Courses within the University of Oxford * The Research Support team in SOGE --- ## Motivation! ![Climbing with a rope](../fig/git-climbing-rope.png) --- ## Motivations - Ability to move back, try things out, 'unlimited undo' - Log of changes to code - Working together, not accidentally overwriting - There is only one 'latest' version - Remote backup (in the cloud) Opportunities - Publishing code in citeable form - Open-source integration with testing, code quality, documentation --- ## Concepts - **repository** a place for a project - **commit** a small set of changes, which accumulate to make a **history** of commits - **remote** repository a place to share a project (Gitlab, Github) - **branch** a way to separate work on new versions, bug-fixes or features --- ## Commits ![Changes Are Saved Sequentially](../fig/play-changes.svg) --- ## Repository ![Commit changes to a repository](../fig/git-repository.svg) --- ## Remote ![Remote Repository After Creation](../fig/git-remote.svg) --- ## Remote ![Remote Repository After remote-add](../fig/git-remote.1.svg) --- ## Remote ![Remote Repository After First Push](../fig/git-remote.2.svg) --- ## Branch ![Different Versions Can be Saved](../fig/versions.svg) --- ## Merge ![Multiple Versions Can be Merged](../fig/merge.svg) --- ## Collaborating with git ![Github flow](../fig/github-flow.png) [https://guides.github.com/introduction/flow/](https://guides.github.com/introduction/flow/) --- ## Live coding in progress ![Kermit typing](../assets/img/typing-kermit.gif) --- ## Summary Starting out `git init` `git clone`
-- Committing `git add ...` `git commit -m "..."`
-- Information `git status` `git log` --- ## Summary Remotes `git push` `git pull`
-- Branches `git branch ...` `git merge ...` `git checkout ...` --- ## Git Documentation `git --help`
Git manual - https://git-scm.com/docs/git Git book - https://git-scm.com/book/en/v2 Cheatsheet from Github - https://education.github.com/git-cheat-sheet-education.pdf --- ## Thanks! Questions? [https://nismod.github.io/presentations/a-short-intro-to-git.html](https://nismod.github.io/presentations/a-short-intro-to-git.html) tom.russell@ouce.ox.ac.uk roald.lemmen@ouce.ox.ac.uk