 ## Using GitHub through R Studio Summer 2020 Eagle I.O Team: + [
](https://www.linkedin.com/in/renatagppr/) Renata Garcia Prieto Palacios Roji + [
](https://www.linkedin.com/in/casey-osorio-duffoo/) Casey Osorio-Duffoo + [
](https://www.linkedin.com/in/noel-d-souza-60101a125/) Noel D'Souza + [
](https://www.linkedin.com/in/john-kulas-184a031/) John Kulas --- ## Topics covered 1. How (and why) to integrate GitHub and R Studio 2. Connecting individual accounts to shared projects 3. Committing, pushing, and pulling 4. How to ask for a task to be completed 5. How to approve tasks {height=500, width=500} --- ## Why you want to do this Using a version control platform (such as [GitHub](https://www.github.com)) facilitates collaboration on projects from multiple people (while restricting the number of *versions* of the collaborative material). RStudio integrates really easily with GitHub, so it turns out to be a very useful way to share scripts and work on projects [such as this current presentation!](https://github.com/jtkulas/GitHub/tree/development)  --- ## How to integrate RStudio and GitHub You need to install "Git" onto your computer before using GitHub through RStudio. This [site](https://happygitwithr.com/install-git.html) as well as the next few slides walk you through the setup. An entire book dedicated to this Git and R Studio integration is [located here](https://happygitwithr.com/)  --- ## Additional tutorials .pull-left[ As you navigate this presentation, if you find yourself stuck, there are also
tutorials located [here](https://youtu.be/lXwH2R4n3RQ) and [here](https://www.youtube.com/watch?v=Pg8LeOfvQME) ] .pull-right[  ] --- ## Installing Git Git is platform tool that helps connect the website [GitHub](https://github.com/), and R studio. To install Git on you computer go to the website <https://git-scm.com/downloads>. Here is what the website should look like:  --- ## What's a "Shell"? At some point you may be asked to operate from within a "shell" (you don't need to do so, but the previous slide's link does ask you to use a shell). A shell is an access point to your computer that operates somewhere behind your operating system (for example, Windows). You can access shells outside of RStudio, but if you'd like to access a shell from *within* RStudio, you can also do so - the "Terminal" tab within RStudio is actually a "shell":  --- ## After you've successfully installed "Git" ### Part 1: Connect Git to R .pull-right[ - Go to Tools in RStudio; it is between "*Profile*" and "*Help*". - Then, click on Global Options - Next, click on Git/SVN ] .pull-left[  ] --- ## Part 2: Connect Git To R Find where you downloaded "Git" and link to the location within the "*Git executable:*" window - On a windows computer, you go to "this PC" - Click on "Windowns (C:)" - Click on "Program Files Folder" - Click on "Git Folder" - Click on "bin folder" - Click on "git.exe"  --- ## Good job!! You are now connect to Github with Rstudio.  --- ## Now Wut?!? Now you need a project to collaborate on. You can use [this current presentation](https://github.com/jtkulas/GitHub/tree/development) as an example project if you wanna be meta!!! (just beware we use some packages that you'll need to install via devtools because they're hosted on GitHub, not CRAN). If meta scares you, you can try a [simpler project](https://github.com/jtkulas/temp/tree/master).  --- ## Connecting to a GitHub repository 1. Go to Github, and click on code, then copy the link 2. From within RStudio, you will go to "New Project" 3. Go to "verison control", click on "Git" 4. Paste the GitHub link   --- ## Problem Solving [This error](https://codewithhugo.com/fix-git-failed-to-push-updates-were-rejected/) was very common, so with the current presentation, we had to bypass it via this command (in the R Studio `terminal` pane)  --- ## Options You can set up notifications via your *global* options (associated with your account - not specific to any one repository):  --- ## Connecting individual accounts to shared projects (Step I) Invite collaborators from within the GitHub repo:  ...you'll need their GitHub username --- ## Connecting individual accounts to shared projects [(Step II)](https://www.youtube.com/watch?v=YxZ8J2rqhEM) First access the GitHub repository url, then, within the R Studio interface follow the wizard via: File `\(\rightarrow\)` *New Project* `\(\rightarrow\)` Version Control `\(\rightarrow\)` Git `\(\rightarrow\)` paste the GitHub repository address into the "Repository URL:" window. Note that you'll also indicate a local (on your computer) location for the files...  --- ## Connecting individual accounts to shared projects (Success) You now have a "project" that you can access from within R Studio, but is linked to the GitHub files (as well as somewhere locally on your computer)  --- ## Then what? You can now work on shared .Rmd files via local editing. A "commit" saves your edits, whereas a "push" sends your saved changes (aka "commits") to the online GitHub repository. There's a decent YouTube overview [here](https://www.youtube.com/watch?v=KjLycV1IWqc)  --- ## Using the repository Especially with shared projects, every time you access the project, make sure to "pull" - this will ensure that you have (locally) the most up-to-date information that is located on the shared repository:  --- ## Forking vs. branching Forks are different paths that a project may take (e.g., point of divergence) toward a different end-goal, whereas branches are shorter-term (typically) "construction zones" where edits can be temporarily held before being integrated into the master branch. There are a couple of good descriptions located [here](https://youtu.be/KDUtjZHIx44?t=658) [here](https://support.atlassian.com/bitbucket-cloud/docs/branch-or-fork-your-repository/) and [here](https://www.pluralsight.com/blog/software-development/the-definitive-guide-to-forks-and-branches-in-git#:~:text=Forking%20creates%20a%20full%20copy,what%20branch%20you%20are%20using.-) If you find a repository that you'd like to copy (e.g., use it as a template), then "fork".  --- ## Defining a new branch Best practice seems to entail creating a branch within which proposed edits can be made and reviewed prior to "pulling" these changes to the master branch (the master is where the initial files were placed, but also where the final product will be located). You can create a new GitHub branch from within RStudio via the `New Branch` option on the `Git` tab of RStudio's "Environment/History" panel:  --- ## Lingering questions... What are all of these files? (they keep multiplying)  Heya --- ## Tasks for next meeting + figure out push and pull + how to request a change + how to stage --- ## Notifications In order to recieve notification that a push has been made to a repository that you own, navigate to the repository, then indicate up to 2 e-mails that you would like to "sign-up" for...  --- ## Notifications (II) If you wish to recieve notifications from a repository that you collaborate on but do not "own", [GitHub has unfortunately depreciated that function](https://github.community/t/get-notified-of-all-commits-to-all-branches-of-a-repo/759). The cleanest workaround that we have found seems to be [to use ggBots](https://www.youtube.com/watch?v=jssX19RsozQ)  --- ## ZZbots! 1. Sign up for a free [zzBots account](https://www.zzbots.com/) 2. Connect your new zzBots account to GitHub 3. Follow the menu to create a new bot 4. Indicate bot name and follow prompts (starting with "send email")  --- ## Issues: Creating an issue, which is similar to creating a task: https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/creating-an-issue How to assign an issue: https://help.github.jp/enterprise/2.11/user/articles/assigning-issues-and-pull-requests-to-other-github-users/#:~:text=Under%20your%20repository%20name%2C%20click,their%20name%20when%20it%20appears. --- ## Pull request: https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request --- ## Watching ...doesn't really seem to do much of anything 