Skip to content

Commit

Permalink
Use a child-document approach for "Make a repo on GitHub"
Browse files Browse the repository at this point in the history
It's barely any shorter, but it will make it easier to keep these sections in sync in the future.
  • Loading branch information
jennybc committed Oct 23, 2021
1 parent cbd5a46 commit 786678a
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 90 deletions.
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Imports:
bslib,
downlit,
fs,
glue,
readr,
sessioninfo,
xml2
Encoding: UTF-8
26 changes: 26 additions & 0 deletions child-create-a-github-repo.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Go to <https://github.com> and make sure you are logged in.

Near "Repositories", click the big green "New" button.
Or, if you are on your own profile page, click on "Repositories", then click the big green "New" button.

How to fill this in:

* Repository template: No template.
* Repository name: <<<repository_name_text>>>
* Description: <<<description_text>>>
* Public.
* Initialize this repository with: Add a README file.

Click the big green button that says "Create repository".

Now click the big green button that says "<> Code".

Copy a clone URL to your clipboard.
If you're taking our default advice, copy the HTTPS URL.
But if you're opting for SSH, then make sure to copy the SSH URL.

```{r}
#| echo = FALSE, fig.align = "center", out.width = "100%",
#| fig.alt = "Selecting an HTTPS vs SSH URL on GitHub"
knitr::include_graphics("img/github-https-or-ssh-url-annotated.png")
```
40 changes: 15 additions & 25 deletions connect-git-github.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,21 @@ I assume you've decided whether to use HTTPS (see chapter \@ref(https-pat) or SS

## Make a repo on GitHub

Go to <https://github.com> and make sure you are logged in.

Near "Repositories", click the big green "New" button.
Or, if you are on your own profile page, click on "Repositories", then click the big green "New" button.

How to fill this in:

* Repository template: No template.
* Repository name: `myrepo` (or whatever you wish, we'll delete this soon anyway).
* Description: "testing my setup" (or whatever, but some text is good for the README).
* Public.
* Initialize this repository with: Add a README file.

Click the big green button that says "Create repository".

Now click the big green button that says "<> Code".

Copy a clone URL to your clipboard.
If you're taking our default advice, copy the HTTPS URL.
But if you're opting for SSH, then make sure to copy the SSH URL.

```{r}
#| echo = FALSE, fig.align = "center", out.width = "100%",
#| fig.alt = "Selecting an HTTPS vs SSH URL on GitHub"
knitr::include_graphics("img/github-https-or-ssh-url-annotated.png")
```{r echo = FALSE, results = "asis"}
dat <- list(
repository_name_text = glue::glue("
`myrepo` or whatever you wish (we'll delete this soon)."),
description_text = glue::glue("
\"Repository for testing my Git/GitHub setup\" or similar. It's nice to \\
have something here, so you'll see it appear in the README.")
)
insert <- glue::glue_data(
dat,
readr::read_file("child-create-a-github-repo.Rmd"),
.open = "<<<", .close = ">>>"
)
res <- knitr::knit_child(text = insert, quiet = TRUE)
cat(res, sep = '\n')
```

## Clone the repo to your local computer
Expand Down
40 changes: 15 additions & 25 deletions connect-rstudio-git-github.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,21 @@ If you don't have a suitable test repository on GitHub, follow the instructions

## Make a repo on GitHub

Go to <https://github.com> and make sure you are logged in.

Near "Repositories", click the big green "New" button.
Or, if you are on your own profile page, click on "Repositories", then click the big green "New" button.

How to fill this in:

* Repository template: No template.
* Repository name: `myrepo` (or whatever you wish, we'll delete this soon anyway).
* Description: "testing my setup" (or whatever, but some text is good for the README).
* Public.
* Initialize this repository with: Add a README file.

Click the big green button that says "Create repository".

Now click the big green button that says "<> Code".

Copy a clone URL to your clipboard.
If you're taking our default advice, copy the HTTPS URL.
But if you're opting for SSH, then make sure to copy the SSH URL.

```{r}
#| echo = FALSE, fig.align = "center", out.width = "100%",
#| fig.alt = "Selecting an HTTPS vs SSH URL on GitHub"
knitr::include_graphics("img/github-https-or-ssh-url-annotated.png")
```{r echo = FALSE, results = "asis"}
dat <- list(
repository_name_text = glue::glue("
`myrepo` or whatever you wish (we'll delete this soon)."),
description_text = glue::glue("
\"Repository for testing my Git/GitHub setup\" or similar. It's nice to \\
have something here, so you'll see it appear in the README.")
)
insert <- glue::glue_data(
dat,
readr::read_file("child-create-a-github-repo.Rmd"),
.open = "<<<", .close = ">>>"
)
res <- knitr::knit_child(text = insert, quiet = TRUE)
cat(res, sep = '\n')
```

## Clone the test GitHub repository to your computer via RStudio
Expand Down
40 changes: 25 additions & 15 deletions usage-existing-project-github-first.Rmd
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
# Existing project, GitHub first {#existing-github-first}

A novice-friendly workflow for bringing an existing R project into the RStudio and Git/GitHub universe.
This is a novice-friendly workflow for bringing an existing R project into the RStudio and Git/GitHub universe.

We do this in a slightly awkward way, in order to avoid using Git at the command line. You won't want to work this way forever, but it's perfectly fine as you're getting started!
We do this in a slightly awkward way, in order to avoid using Git at the command line.
You won't want to work this way forever, but it's perfectly fine as you're getting started!

We assume you've got your existing R project isolated in a directory on your computer. If that's not already true, make it so. Create a directory and marshal all the existing data and R scripts there. It doesn't really matter where you do this, but note where the project currently lives.
We assume you've got your existing R project isolated in a directory on your computer.
If that's not already true, make it so.
Create a directory and marshal all the existing data and R scripts there.
It doesn't really matter where you do this, but note where the project currently lives.

## Make a repo on GitHub

Go to <https://github.com> and make sure you are logged in.

Click the green "New repository" button. Or, if you are on your own profile page, click on "Repositories", then click the green "New" button.

Pick a repository name that actually reminds you what the project is about! But try to be concise.

Public
YES Initialize this repository with a README

Click the big green button "Create repository."

Copy the HTTPS clone URL to your clipboard via the green "Clone or Download" button. Or copy the SSH URL if you chose to set up SSH keys.
```{r echo = FALSE, results = "asis"}
dat <- list(
repository_name_text = glue::glue("
`myrepo` or a similarly short name for this existing project. Approach \\
this similar to a variable name, in code: descriptive but brief, no \\
whitespace. Letters, digits, `-`, `.`, or `_` are allowed."),
description_text = glue::glue("
\"Analysis of the stuff\" or any short description of the project. Write \\
this for humans.")
)
insert <- glue::glue_data(
dat,
readr::read_file("child-create-a-github-repo.Rmd"),
.open = "<<<", .close = ">>>"
)
res <- knitr::knit_child(text = insert, quiet = TRUE)
cat(res, sep = '\n')
```

## New RStudio Project via git clone

Expand Down
42 changes: 17 additions & 25 deletions usage-new-project-github-first.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,23 @@ We will specify below when you may need to do something differently.

## Make a repo on GitHub

Go to <https://github.com> and make sure you are logged in.

Near "Repositories", click the big green "New" button.
Or, if you are on your own profile page, click on "Repositories", then click the big green "New" button.

How to fill this in:

* Repository template: No template.
* Repository name: `myrepo` (or whatever you wish, we'll delete this soon anyway).
* Description: "testing my setup" (or whatever, but some text is good for the README).
* Public.
* Initialize this repository with: Add a README file.

Click the big green button that says "Create repository".

Now click the big green button that says "<> Code".

Copy a clone URL to your clipboard.
If you're taking our default advice, copy the HTTPS URL.
But if you're opting for SSH, then make sure to copy the SSH URL.

```{r}
#| echo = FALSE, fig.align = "center", out.width = "100%",
#| fig.alt = "Selecting an HTTPS vs SSH URL on GitHub"
knitr::include_graphics("img/github-https-or-ssh-url-annotated.png")
```{r echo = FALSE, results = "asis"}
dat <- list(
repository_name_text = glue::glue("
`myrepo` or whatever you wish to name your new project. Approach this \\
similar to a variable name, in code: descriptive but brief, no \\
whitespace. Letters, digits, `-`, `.`, or `_` are allowed."),
description_text = glue::glue("
\"Analysis of the stuff\" or any short description of the project. Write \\
this for humans.")
)
insert <- glue::glue_data(
dat,
readr::read_file("child-create-a-github-repo.Rmd"),
.open = "<<<", .close = ">>>"
)
res <- knitr::knit_child(text = insert, quiet = TRUE)
cat(res, sep = '\n')
```

### GitLab
Expand Down

0 comments on commit 786678a

Please sign in to comment.