Skip to content

Commit

Permalink
RStudio in archaeology, sharing, local-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdarst committed Mar 12, 2024
1 parent 4f2da37 commit 9afad40
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 3 deletions.
50 changes: 49 additions & 1 deletion content/archaeology.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ some error message printed.
Searching with the magnifying glass from the left sidebar is
equivalent to `git grep`.
::::

::::{group-tab} RStudio
Edit → Find in files.

Use the command line method for more power.
::::
:::::


Expand Down Expand Up @@ -134,6 +140,16 @@ some error message printed.
explorer shows changes to *that file*. You can click on a change
to see the details.
::::

::::{group-tab} RStudio
The graph view lets you select certain commits for viewing. The search box lets you search for a certain commit by hash.

:::{figure} img/commits/rstudio-graph-view.png
:class: with-border
:width: 80%
:alt: RStudio screenshot as described
:::
::::
:::::


Expand Down Expand Up @@ -177,6 +193,11 @@ modified each line. Incredibly useful for reproducibility.
It seems this needs an extension. We'd recommend trying the
command line method for now.
::::

::::{group-tab} RStudio
Use the command line method (from what we can tell).
::::

:::::

:::{discussion}
Expand Down Expand Up @@ -242,6 +263,10 @@ Discuss how these relatively trivial changes affect the annotation:

Make sure you change back to the main branch when you are done.
::::

::::{group-tab} RStudio
It seems you can only create branches from the present (at least without extensions). Use the command line method.
::::
:::::


Expand Down Expand Up @@ -276,8 +301,17 @@ you can translate to the other options.
::::

::::{group-tab} VS Code
"File" -> "New Window".
**Warning: many of these exercise tasks aren't possible in the VS Code interface without extensions. You can use VS Code to clone the project, but be prepared to start the terminal to do the main tasks.**

"File" → "New Window".
::::

::::{group-tab} RStudio
**Warning: many of these exercise tasks aren't possible in the RStudio interface. You can use RStudio to clone the project, but be prepared to start the terminal to do the main tasks.**

File → New Project.
::::

:::::

- Clone this repository:
Expand All @@ -297,6 +331,11 @@ you can translate to the other options.
From a new VS Code window, select "Clone Git repository" and enter
that URL.
::::

::::{group-tab} RStudio
From the new project window, choose Version Control → Git → and enter the URL
::::

:::::

- Then let us all **make sure we are working on a well-defined version** of the repository.
Expand All @@ -322,6 +361,15 @@ you can translate to the other options.
::::{group-tab} VS Code
Switch to "Source Control", then the "..." menu, then "Branch", then "Create new branch from..." and select "networkx-2.6.3".
::::

::::{group-tab} RStudio
Use the command line method (but you don't need to `cd networkx`, the RStudio terminal starts in the right place.) So, run this:
```console
$ git switch --create exercise networkx-2.6.3
```
(and if it doesn't work, check Command Line for the command for older git)
::::

:::::

Then using the above toolbox try to:
Expand Down
Binary file added content/img/commits/rstudio-commit-message.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/img/commits/rstudio-committing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/img/commits/rstudio-create-branch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/img/commits/rstudio-graph-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 98 additions & 2 deletions content/local-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ click on the "Clone Repository" button.

Paste in this URL: `https://github.com/USER/recipe-book` (replace `USER`)
::::::

::::::{group-tab} RStudio
(This pathway is in draft stage: we don't have screenshots yet.)

You can clone a repository via File → New Project → Version Control →
Git.

Enter the repository URL: see "command line" instructions for hints
here. RStudio, like most things, uses regular Git in the background
so all the same command line choices apply: see part (1). We'd
recommend SSH if possible.
::::::

:::::::


Expand Down Expand Up @@ -157,6 +170,28 @@ $ git switch --create another-recipe

Creating a new branch in VS Code.
::::

::::{group-tab} RStudio
The main way to control git is via teh Git tab in the right side
panel: it's a tab along with "Environment", "History", etc. This will
be called the "Git tab".

From the git tab, branches are controlled on the right side of the
icon bar. The purple button allows creating branches and the drop-down next to it allows switching. If you select "Sync branch with remote", it will push that branch (with no commits on it) to the remote immediately.


```{figure} img/commits/rstudio-create-branch.png
:width: 80%
:class: with-border
:alt: RStudio screenshot of create branch
Creating a branch in RStudio
```


::::


:::::


Expand Down Expand Up @@ -188,6 +223,30 @@ and to replace "Short summary of the change" with a meaningful commit message.
Committing a new file in VS Code.
:::
::::

::::{group-tab} RStudio

1. One creates the file in the normal way,
1. In the git tab, one uses the checkbox under "Staged" to add mark the file as {term}`staged <staging area>`, which means it will be committed next.
1. Click the checkmarks to commit. A new window will be opened.

:::{figure} img/commits/rstudio-committing.png
:alt: Screenshot of RStudio commit process
:width: 80%
:class: with-border

Staging and commiting file in RStudio.
:::

The commit message corresponds to what you would see on the command line (we haven't learned these diff commands yet, but are mentioned in {doc}`staging-area`):

:::{figure} img/commits/rstudio-commit-message.png
:alt: Screenshot of RStudio commit message entry
:width: 80%
:class: with-border
::::


:::::


Expand Down Expand Up @@ -217,6 +276,14 @@ Repeat the same steps as above.

Switching branch via selector at bottom.
::::

::::{group-tab} RStudio
Switch to the `main` branch again, via the branch switcher right next to the "create new branch" button (see step (3)).

Commit like before.
::::


:::::


Expand Down Expand Up @@ -254,6 +321,11 @@ Just like with the command line, when we merge we modify our *current* branch.
:width: 80%
:class: with-border
::::

::::{group-tab} RStudio
It doesn't seem theer is a graphical way to do this. Luckily, like usual, via the Terminal you can use the "Command line" method.
::::

:::::


Expand All @@ -275,9 +347,8 @@ aliases: {ref}`aliases`.

Compare this with the graph on GitHub: Insights tab → Network view (just like
we have done before).

The result is that we should not be able to see the new branch and the new
commits on GitHub.
commits on GitHub (since we haven't pushed it to GitHub yet - it is only local work so far).
::::

::::{group-tab} VS Code
Expand All @@ -290,6 +361,26 @@ This requires an extension. Opening the VS Code terminal lets you use the comma

View → Terminal will open a terminal at bottom. This is a normal command line interface and very useful for work. (Note the git-aware prompt that shows the current branch. This requires other setup.)
::::

::::{group-tab} RStudio
You can find a graph view in RStudio, but it doesn't seem you can compare arbitrary commits without an extension. Luckily, the command line method works, as usual.

1. From the git tab,
1. Select the clock icon to go to "History" view
1. Select "(all branches)" to see full graph (equivalent of `--all` in the command line)

:::{figure} img/commits/rstudio-graph-view.png
:class: with-border
:width: 80%
:alt: RStudio screenshot as described
::::

Compare this with the graph on GitHub: Insights tab → Network view (just like
we have done before).
The result is that we should not be able to see the new branch and the new
commits on GitHub (since we haven't pushed it to GitHub yet - it is only local work so far).


:::::


Expand Down Expand Up @@ -353,6 +444,11 @@ Source Control button on left sidebar → Three dots in upper right of source co

Then select the remote branch you want to create a local branch from.
::::

::::{group-tab} RStudio
The branch picker also lists branches on remotes. If you click on of them, it will create a local branch and track it.
::::

:::::


Expand Down
27 changes: 27 additions & 0 deletions content/sharing.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,33 @@ online!
repositories, don't do this unless you are very sure what is happening.
:::

:::{group-tab} RStudio

This is not fully explained, because a lot of it is similar to the "Command line" method (and an RStudio expert could help us some). The main differeences are:

### Put your project under version conrol

1. Tools → Version control → Project setup → Version conrol system = Git.
1. Select "Yes" for "do you want to initialize a new git repository for this project.
1. Select yes to restart the project with RStudio.
1. Switch to branch `main` to have you branch named that.

### Create an <u>empty</u> repository on GitHub

Same as command line

### Push an existing repository from your computer to GitHub

1. Under the "Create new branch" button → "Add Remote"
1. Remote name: `origin`
1. Remote URL: as in command line (remember to select SSH or HTTPS as you have configured your RStudio)
1. The "Push" (up arrow) button will send changes on your current branch to the remote. The "Pull" (down arrow) will get changes from the remote.

### Troubleshooting

Same as command line

:::
::::
:::::

Expand Down

0 comments on commit 9afad40

Please sign in to comment.