Version control with git Eike Mueller, University of Bath Wed 26 th Sep 2018 Eike Mueller, University of Bath Version control with git
Why version control? “Piled Higher and Deeper” by Jorge Cham, http://www.phdcomics.com Eike Mueller, University of Bath Version control with git
Version control Benefits of Version control Systematic and controlled Backup Collaborate : work on same document simultaneously Keep track of changes (who introduced feature X and why?) Try out changes and revert to working version (“undo”-button) Work on project on different machines Simplifies debugging Reproducibility What’s the catch? Have to learn a few commands to interact with git Enforces organised approach Eike Mueller, University of Bath Version control with git
Applications Version control can be be applied to: Source code (matlab, Fortran, C, Python, . . . ) LaTeX (papers, reports, your thesis, . . . ) Raw results (e.g. CSV files with numerical values) Any text files 1 Reproducibility: Link results to particular code version 1 Binary files work as well, but harder to track changes Eike Mueller, University of Bath Version control with git
Basic concepts Tracking of changes Merging and resolving Collaborating conflicts All figures from Software Carpentry webpage Eike Mueller, University of Bath Version control with git
git Why git? de-facto standard now (supersedes subversion, CVS, . . . ) Several nice features: Work remotely (distributed system allows offline commits ) Simple and lightweight branching ⇒ encourages experimentation Selective commits ( staging area) Very powerful Not the easiest system to learn We’ll only cover the basics here Lots of online resources Graphical interfaces (e.g. SourceTree) Documentation Git book: http://git-scm.com/book/en/v2 Reference: http://git-scm.com/docs Eike Mueller, University of Bath Version control with git
Overview Session 1 (Basics) 13:45h - 15:00h Creating a git repository Tracking changes Exploring history — break — Session 2 (Collaborating) 15:30h - 17:00h Working with remotes (github) Collaborating and resolving conflicts Wrapup and advanced concepts (branching, merging, . . . ) Resources available at 2 http://people.bath.ac.uk/rjg20/training/ 2 All material used is based on Software Carpentry webpage http://software-carpentry.org/ Eike Mueller, University of Bath Version control with git
Eike Mueller, University of Bath Version control with git
github Create a github account go to https://github.com/ click here Use your University email address Eike Mueller, University of Bath Version control with git
Eike Mueller, University of Bath Version control with git
Wrapup Summary Track changes and collaborate Pays off even for small projects Small number of commands git log 1 git status 2 git add 3 git commit 4 git clone/push/pull 5 There are graphical tools (e.g. SourceTree for Mac/Win) Other hosting sites: BitBucket, GitLab More details Git book: http://git-scm.com/book/en/v2 Reference: http://git-scm.com/docs Eike Mueller, University of Bath Version control with git
Advanced topics Advanced topics What actually is a commit? Branching and merging, the rebase command Rewriting history Pull requests Advanced workflows Forking repositories Tags Stashing Eike Mueller, University of Bath Version control with git
Branches A Quick glance at branches Branches allow organised simultaneous development by collecting related commits Bugfix New untested feature Master branch (guaranteed to work) Usually: 1 concept/feature = 1 branch https://git-scm.com/book git branch = lightweight pointer Eike Mueller, University of Bath Version control with git
Branches Merge and resolve conflicts Basic merge and rebase Pull requests on github and BitBucket Code review Can limit access to master branch https://git-scm.com/book Eike Mueller, University of Bath Version control with git
Recommend
More recommend