A few weeks ago, we learned how to contribute to a Github repository on which you are a collaborator. The goal was to modify the content directly. This works if two conditions are met:
This may not always be the case. In fact, it’s possible that you and your collaboror(s) on this repository may be contributing edits and additions to the same files and folder simultaneously. This will undoubtedly create conflicts which will need to be resolved by at least one person with appropriate permissions to the repo.
But, there are far better ways to collaborate on GitHub without runnign into these pesky problems! We will be visiting two main techniques today.
For today’s exercise, you will be performing roles of two collaborators simultaneously. For this reason, do the following:
Get a second github account (first, you will need to get a second email address. You can’t use the same email address for two different github accounts).
Sign into this new account using an incognito browser window
Sign into your regular github account using normal browser window
We will refer to these two accounts as follows. Your account names will be different obviously, so make sure to keep track of which is which.
penguin (original account)
puffin (the incognito account)
~/.ssh/config file accordingly. But I have found it to be a hassle and having separate keys simplifies things.ssh-keygen -t rsa -b 4096 -C "your_new_email@host.com"id_rsa.*. I would something like id_rsa_puffin where puffin refers to your second github account.~/.ssh/config file as follows:Host puffin.github.com
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_puffincd ~/.ssh/
pbcopy < id_rsa_puffin.pubIn your incognito browser window, go inside your github account, and add the copied key. Name it accordingly on the website form.
Now you are ready to rock n roll.
branchesThis section assumes that your workflow is that of a collaborator.
penguin invites puffinWith your penguin account, create a new private repository named climate.
Leave all options unchecked
Invite your puffin account as a collaborator
In your puffin account, accept the invitation
penguin generates initial contentclimate and initialize it as a git repocd ~/Github
mkdir climate
cd climate
git init---
title: Climate Change from 1983 to 2008
---
## Exploratory Data Analysis (EDA)
- Import the data into R and check variable names.library(tidyverse)
library(plotly)
library("RColorBrewer")
climate <- read_csv("data/climate_change.csv")
names(climate)- Check how the data is organizedstr(climate)
spec_tbl_df [308 × 11] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
$ Year : num [1:308] 1983 1983 1983 1983 1983 ...
$ Month : num [1:308] 5 6 7 8 9 10 11 12 1 2 ...
$ MEI : num [1:308] 2.556 2.167 1.741 1.13 0.428 ...
$ CO2 : num [1:308] 346 346 344 342 340 ...
$ CH4 : num [1:308] 1639 1634 1633 1631 1648 ...
$ N2O : num [1:308] 304 304 304 304 304 ...
$ CFC-11 : num [1:308] 191 192 193 194 194 ...
$ CFC-12 : num [1:308] 350 352 354 356 357 ...
$ TSI : num [1:308] 1366 1366 1366 1366 1366 ...
$ Aerosols: num [1:308] 0.0863 0.0794 0.0731 0.0673 0.0619 0.0569 0.0524 0.0486 0.0451 0.0416 ...
$ Temp : num [1:308] 0.109 0.118 0.137 0.176 0.149 0.093 0.232 0.078 0.089 0.013 ...
- attr(*, "spec")=
.. cols(
.. Year = col_double(),
.. Month = col_double(),
.. MEI = col_double(),
.. CO2 = col_double(),
.. CH4 = col_double(),
.. N2O = col_double(),
.. `CFC-11` = col_double(),
.. `CFC-12` = col_double(),
.. TSI = col_double(),
.. Aerosols = col_double(),
.. Temp = col_double()
.. )- Explore the change in CO2 levels over the years using a barplot.climate_change_chart <- ggplot(climate, aes(x = Year, y = Temp, fill = CO2)) +
xlab("Year") +
ylab("Temperature") +
theme_minimal(base_size = 14)barplot <- climate_change_chart +
geom_bar(position = "dodge", stat = "identity", color = "white")
ggplotly(barplot)
ggsave("co2_1983_2008.png")<center>
<img src="co2_1983_2008.png" width=750 />
</center>git config user.name "penguin"
git config user.email "penguin@arctic.info"
git remote add origin git@github.com:penguin/climate.gitadd, commit and push the repo upstream.git add .
git commit -m "initial commit by penguin"
git push -u origin masterpuffin clones the repocd ~/
mkdir Github2
cd Github2
ssh-add ~/.ssh/id_rsa_puffin
git clone git@github.com:penguin/climate.gitpuffin creates a new branchgit branch
* mastergit checkout -b puffin-update## Temperature changes through timelibrary(lubridate)
climate_change_ymd <- climate %>%
mutate(year_month = ymd(paste(climate$Year, climate$Month, truncated = 1)))
L1 <- ggplot(climate_change_ymd, aes(year_month, Temp)) +
geom_line() +
geom_smooth(se=FALSE, linetype="dotted") +
labs(title = "Temperature (1983-2008)",
x = "Year",
y = "Temperature") +
theme(plot.title = element_text(hjust=0.5))
ggplotly(L1)
ggsave("temperature_years.png")<center>
<img src="temperature_years.png" width=750 />
</center>puffin pushes new branch upstreamgit config user.name "puffin"
git config user.email "puffin@arctic.com"
git config --list
git remote -vadd, commit and push the new branch upstreamgit add .
git commit -m "Updated README.md
git push -u origin puffin-updatepenguin merges the new branch into mainGo to the github account for penguin and visit the repo located at https://github.com/penguin/climate.
In the Pull requests tab, choose new pull request
From the dropdown menu, choose
Then hit Create pull request.
Github will notify you if this branch can be merged or if there are any conflicts to be resolved. Take appropriate action.
forks