]" />
class: center, middle, inverse, title-slide # Git & GitHub ## in R & Rstudio ### .left[
Anna Krystalli Β
<i class="fab fa-twitter faa-float animated "></i>@annakrystalli
] ### Hacktoberbest 2019 Kickoff --- # Overview - ### Setting up git & GitHub through R - ### Working with git in Rstudio - ### Practical: Forking and making a Pull Request! --- # Prerequisites ### You will need: - Git [installed](https://carpentries.github.io/workshop-template/#git) - A [GitHub](https://github.com/) account - Your account registered with [Hacktoberfest](https://hacktoberfest.digitalocean.com/)* (optional: for your PR to count) - to be Connected to the Internet! Select **_TheCloud** and follow instructions to get connected. --- # Git, Github & Rstudio #### Before: git only through the terminal π’ or external GUI -- ### Now: Rstudio + `usethis` π¦ == β€οΈ `Git` & `GitHub` π€© .center[  ] --- # Configure git & GitHub ### Configure git **Set your configuration** Use your github username and and the email you used to sign-up on GitHub ```r usethis::use_git_config( user.name = "Jane", user.email = "jane@example.org") ``` --- ### Configure GitHub authentication #### Get GITHUB Personal Authorisation Token ```r usethis::browse_github_pat() ``` <img src="assets/browse_github.png" height="300px"> --- ### Store in `.Renviron` file ```r usethis::edit_r_environ() ``` <img src="assets/GITHUB_PAT.png" height="400px"> --- # Initialise git ### Initialise **Rstudio project** with Git by **just checking a box!** It's now **a repository** <img src="assets/project_git.png" height="200px"> Forgot to? use `usethis::use_git()` --- # Git panel ### Integrated graphical user interface .center[ <img src="assets/git_tab.png" height="300px"> ] --- # Git Rstudio workflow .pull-left[ #### view file status <img src="assets/git_view.png" height="150px"> #### stage files <img src="assets/git_add.png" height="150px"> ] .pull-right[ #### commit changes <img src="assets/git_commit.png" width="600px"> ] --- # Share on GitHub #### Create repo ```r usethis::use_github(protocol = "https") ``` <img src="assets/my_awesome_repo.png" width="500px"> #### Push further changes <img src="assets/push_github.png" height="50px"> --- class: inverse, center, middle # #Evolottery ### Welcome to the evolutionary lottery of skull and beak morphology Sign up for Hacktoberfest so the pull request counts towards your tally! --- ## **#EvoLottery** #### **Beak and skull shapes in birds of prey (βraptorsβ) are strongly coupled and largely controlled by size.** .pull-left[ - In this exercise, each participant will **fork a GitHub repo**, and **contribute a file** required to simulate the *evolutionary trajectory of an imaginary species' body size*. - We'll use **GitHub to collate all species files** and **plot** them all up together at the end! We'll also **discover the skull and beak shapes** associated with each simulated species size. ] .pull-right[  ] --- class: inverse, center, middle # GO! π --- ## **GitHub:** **start with a repo** #### [bit.ly/evolottery](http://bit.ly/evolottery) <img src="assets/repo.png" width="700px" /> --- class: inverse, center, middle # Fork repo --- ## **GitHub:** make your **own copy of the repository** on GitHub - fork are linked and traceable <img src="assets/fork-1.png" width="700px" /> --- ## **GitHub:** GitHub makes a **copy into your account** <img src="assets/fork-2.png" width="700px" /> --- ## **GitHub:** **clone it: copy repo link** to create Rstudio project <img src="assets/fork-3.png" width="700px" /> --- class: inverse, center, middle # Clone project in Rstudio --- ## **rstudio:** Create **new project** <img src="assets/newproj-1.png" width="700px" /> --- ## **rstudio:** Checkout from **version control repository** <img src="assets/newproj-2.png" width="700px" /> --- ## **rstudio:** Clone project from a **git** repository <img src="assets/newproj-3.png" width="700px" /> --- ## **rstudio:** Paste **repo link copied from GitHub** into **Repository URL** field. Click **`Create Project`**. <img src="assets/newproj-4.png" width="700px" /> --- ## **rstudio:** Rstudio project now **contains all files from the GitHub repo.** <img src="assets/newproj-5.png" width="700px" /> --- class: inverse, center, middle # Make a change to the repo --- ## **rstudio:** open **`params/params_tmpl.R`** <img src="assets/edit-1.png" width="700px" /> --- ## **rstudio:** <div class="inverse"><strong>SAVE AS NEW <code>.R</code> script in <code>params/</code> folder</strong></div> Use species name of your choice to name new file. Please **!!DO NOT OVERWRITE `params/params_tmpl.R`!!**. <img src="assets/edit-2.png" width="700px" /> --- ## **rstudio:** edit file with parameters of your choice and save. <img src="assets/edit-3.png" width="700px" /> --- ### The parameters each participants need to supply are: **NB: remember to save the changes to your file** - **`sig2`:** A numeric value greater than 0 but smaller than 5 - **`species.name`:** a character string e.g. `"anas_krystallinus"`. Try to create a species name out of your name! - **`color`:** a character string e.g. `"red"`, `"#FFFFFF"` (Check out list of [**colours in R**](http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf)) --- class: inverse, center, middle # Commit changes locally to git --- ## **rstudio:** in the *git* tab, select the **new file** you created and click **`Commit`**. ### !! Please **ONLY COMMIT YOUR NEW FILE** !! <img src="assets/commit-1.png" width="700px" /> --- ## **rstudio:** write an informative commit message and click **`Commit`** <img src="assets/commit-2.png" width="700px" /> --- ## **rstudio:** your new file has now been commited <img src="assets/commit-3.png" width="700px" /> --- class: inverse, center, middle # Push changes to GitHub --- ## **rstudio:** on the *git* tab click β§ to **push changes to GitHub** <img src="assets/push-1.png" width="700px" /> --- ## **rstudio:** changes have now been updated in the **GitHub repo** <img src="assets/push-2.png" width="700px" /> --- class: inverse, center, middle # Create pull request --- ## **GitHub:** in your repository, create **`new pull request`** to merge fork to master repo (ie the original repo you forked) <img src="assets/merge-1.png" width="700px" /> --- ## **GitHub:** GitHub checks whether your requested merge creates any coflicts. If all is good, click on **`Create pull request`** <img src="assets/merge-2.png" width="700px" /> --- ## **GitHub:** write an informative message explaining your changes to the master repo administrators. Click on **`Create pull request`** <img src="assets/merge-3.png" width="700px" /> --- ## **GitHub:** check original repo to see **your merged changes** <img src="assets/merged.png" width="700px" /> --- ## Check out the merged and [plotted contributions!](https://rse.shef.ac.uk/collaborative_github_exercise/plot_trait_evolution.html) --- background-image: assets/hacktober19_slide.png # Go forth and make PRs! You need **3 more** to get your snazzy t-shirt! ### Join us at a π©βπ» π¨βπ» session! **Meeting room 1, the Diamond, 5:30 pm to 8:00 pm** _The University of Sheffield, 32 Leavygreave Rd, S3 7RD_ - 8th October - 15th October - 22nd October - 29th October Hack together and get support from a member of the [Sheffield Research Software Engineering](https://rse.shef.ac.uk/) team if you get stuck!