Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
Version control with git
Eike Mueller, University of Bath
Wed 26th 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 controlSystematic 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 files1
Reproducibility: Link results to particular code version
1Binary files work as well, but harder to track changesEike Mueller, University of Bath Version control with git
Basic concepts
Tracking of changes
Collaborating Merging and resolvingconflicts
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 experimentationSelective commits (staging area)Very powerful
Not the easiest system to learn
We’ll only cover the basics hereLots of online resourcesGraphical interfaces (e.g. SourceTree)
DocumentationGit 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 at2
http://people.bath.ac.uk/rjg20/training/
2All material used is based on Software Carpentry webpagehttp://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
SummaryTrack changes and collaborate
Pays off even for small projects
Small number of commands1 git log2 git status3 git add4 git commit5 git clone/push/pull
There are graphical tools (e.g. SourceTree for Mac/Win)
Other hosting sites: BitBucket, GitLab
More detailsGit 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 topicsWhat 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 branchesBranches allow organised simultaneous development by collectingrelated 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