class: center, middle, inverse, title-slide # Workflow ## GitHub ### Ben Baumer ### SDS 192Oct 9, 2020(
http://beanumber.github.io/sds192/lectures/mdsr_workflow_01-github.html
) --- class: center, middle, inverse # Reproducibility --- ## Think back to every time... - The results in Table 1 don't seem to correspond to those in Figure 2. - In what order do I run these scripts? - Where did we get this data file? - Why did I omit those samples? - How did I make that figure? - "Your script is now giving an error." - "The attached is similar to the code we used." <br> .footnote[Mine Cetinkaya-Rundel, Karl Broman] --- ## No collaborators? .pull-left[ > Your closest collaborator is you six months ago, <br> but you don’t reply to emails. </br> -- Mark Holder ] .pull-right[ ![](https://media.giphy.com/media/Qw4X3Fsf0N1VqFFUiBi/giphy.gif) ] --- ## Toolchain .pull-left[ 1 Version control <img src="http://femgineer.com/images/logos/github-logo.png" height="150px"> <hr> 2 Literate programming <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Markdown-mark.svg/2000px-Markdown-mark.svg.png" height="150px"> ] .pull-right[ 3 Scriptability <img src="http://rprogramming.net/wp-content/uploads/2012/10/R-Programming.png" height="150px"> <hr> 4 All of the above <img src="https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Gray.png" height="150px"> ] --- class: middle, center, inverse # Version control --- ## What is version control? - a system that records changes to files over time - recall specific versions later --- ## Bad .center[![](../gfx/phd_comics_vc.gif)] .footnote[Piled Higher and Deeper by Jorge Cham, http://www.phdcomics.com.] --- ## Still bad, but not quite as bad ~~~ 2013-10-14_manuscriptFish.doc 2013-10-30_manuscriptFish.doc 2013-11-05_manusctiptFish_intitialRyanEdits.doc 2013-11-10_manuscriptFish.doc 2013-11-11_manuscriptFish.doc 2013-11-15_manuscriptFish.doc 2013-11-30_manuscriptFish.doc 2013-12-01_manuscriptFish.doc 2013-12-02_manuscriptFish_PNASsubmitted.doc 2014-01-03_manuscriptFish_PLOSsubmitted.doc 2014-02-15_manuscriptFish_PLOSrevision.doc 2014-03-14_manuscriptFish_PLOSpublished.doc ~~~ --- ## Better - Saving everything together at once Everytime you save: - zip the entire directory - save it with a date --- ## Best - Version Control <center> <img src="../gfx//repo.png" width="600px" /> </center> <br> .footnote[https://github.com/beanumber/project-tier-clark] --- ## Basic version control - Start with a base version - Save just the changes - Think of it as a tape: - rewind the tape - play back each change ![](../gfx/play-changes.png) .footnote[[Software Carpentry](https://software-carpentry.org/)] --- ## Collaboration with version control .pull-left[ - Multiple people can contribute changes - "Playing back" different sets of changes - different versions of the document. ] .pull-right[ ![](../gfx/merge.png) ] .footnote[[Software Carpentry](https://software-carpentry.org/)] --- ## git/GitHub .pull-left[ `git` - CLI program that does the work - OS-specific install - need it working to use GitHub - `git pull`, `git push`, etc. ] .pull-right[ GitHub - web hosting for `git` projects - Integrated with [RStudio](http://www.rstudio.com) - strong community - additional tools to enhance collaboration - a common location to share your work ] --- ## Commits .center[![](../gfx/commits.png)] --- ## Diff .center[![](../gfx//diff.png)] --- ## git/GitHub, why? - Automatic tracking of changes - No download/upload - Ease of collaboration with ability to resolve merge conflicts - Searchability - Issues, releases, and milestones - N.B. - Visibility: - By default, GitHub repositories are **public**. - We have **private** repositories for education or research --- ## Alternatives - Dropbox: - Pros: easy, seamless - Cons: no simulataneous editing, very limited version control - Google Docs: - Pros: easy, simultaneous editing - Cons: no version control, can't directly read code into R --- ## GitHub procedure .pull-left[ 1. **pull** new changes 2. make edits on your computer 3. **commit** your local changes 1. this step may be repeated 4. **pull** again to avoid merge conflicts 5. **push** your commit(s) to GitHub ] .pull-right[ ![](https://media.giphy.com/media/3oD3YveOJWdwIAfZ5e/giphy.gif) ] --- ## GitHub advice - make small, frequent commits! - always **pull** before you **push** - flag us if you get into trouble - Cheatsheets: - (https://education.github.com/git-cheat-sheet-education.pdf) - (https://www.git-tower.com/blog/git-cheat-sheet/) --- ## [Happy Git and GitHub for the useR](http://happygitwithr.com/) .center[![](http://happygitwithr.com/img/watch-me-diff-watch-me-rebase-smaller.png)]