Collaborative coding with GitHub and Rstudio

EvoLottery

EvoLottery

Welcome to the evolutionary lottery of skull and beak morphology



Beak and skull shapes in birds of prey (“raptors”) are strongly coupled and largely controlled by size.
  • 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.

Start!

Clone Github repo

Start with GitHub repo

https://github.com/r-rse/evolottery

Fork it

make your own copy of the repository on GitHub. Fork are linked and traceable

GitHub asks you to confirm some details:

And makes a copy in your account:

You now have a copy in your account!


Copy repo URL

copy repo link to create a new Rstudio project from the repository.

Create new project in Posit Cloud from GitHub

Checkout from version control repository

Clone project from a git repository

Paste repo link copied from GitHub into Repository URL field. Click Create Project.

Rstudio project now contains all files from the GitHub repo.

In your own personal workspace, create a new project from a GitHub repository.

Paste repo link copied from GitHub into Repository URL field. Click Create Project.

You now have a copy of the materials in you Posit Cloud account, ready to work with!

Make a change to the repo

Make a copy of params_tmpl.R

Please DO NOT OVERWRITE params/params_tmpl.R.

Click on the params/ folder to open it, select params_tmpl.R and click on and Copy.

Use species name of your choice to name new file.

Edit new params file

Open params file

## Edit params file

Edit file with parameters of your choice and save.

Please DO NOT OVERWRITE params/params_tmpl.R.

The parameters each participants need to supply are:

  • 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)

NB: remember to save the changes to your file

Commit changes locally to git

In the git tab, select the new file you created and click Commit.

Please ONLY COMMIT YOUR NEW FILE

Write an informative commit message and click Commit

your new file has now been commited

Push changes to GitHub

on the git tab click ⇧ to push changes to GitHub

changes have now been updated in the GitHub repo

Create pull request

In your repository, create new pull request to merge fork to master repo (ie the original repo you forked)

GitHub checks whether your requested merge creates any coflicts. If all is good, click on Create pull request

Write an informative message explaining your changes to the master repo administrators. Click on Create pull request

The repository owner will then review your PR and either merge it in or respond with some guidance if they spot a problem.

Check original repo to see your merged changes

We’ll merge all contributions and plot them together at the end!

Now that everyone has contributed to the r-rse repository (the upstream repository), the params/ folder contains a number of files, one for each successful pull request.

However your local copy of the repository only contains the template and your own file.

Q: How can I merge changes from the upstream repository to my local repository?

Add upstream remote

Check current remotes

We can check the urls of remotes currently linked to our local repo using usethis::git_remotes().

usethis::git_remotes()
$origin
[1] "https://github.com/annakrystalli/evolottery.git"

We see that only my form is currently listed as a remote under the name origin.

Add the r-rse repo as upstream

To add a new remote we need the https url of the upstream repo (the equivalent of the one we used to create our project from our fork through version control) which in this case is https://github.com/r-rse/evolottery.

We can then use usethis::use_git_remote() to set the upstream repository:

usethis::use_git_remote(
    name = "upstream", 
    url = "https://github.com/r-rse/evolottery.git")

We can check that everything was set correctly with usethis::git_remotes()

usethis::git_remotes()
$origin
[1] "https://github.com/annakrystalli/evolottery.git"

$upstream
[1] "https://github.com/r-rse/evolottery.git"

Synch with upstream

Finally, to synch with the upstream repository we can now use function usethis::pr_merge_main(). This fetches the master branch from the upstream repository and merges it into our own local master branch.

usethis::pr_merge_main()
✔ Pulling changes from 'upstream/main'.

You should now have all participant files in the params/ folder and will be able to generate all bird skulls if you run plot_trait_evolution.Rmd locally.

Synch origin

To also synch your origin remote repository you can simply push the merged upstream changes up to GitHub.

Back to top