Skip to content

Commit

Permalink
hw8 posted
Browse files Browse the repository at this point in the history
  • Loading branch information
ionides committed Nov 6, 2024
1 parent e602c6b commit c383cf4
Show file tree
Hide file tree
Showing 6 changed files with 854 additions and 5 deletions.
Binary file added git-history.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
191 changes: 191 additions & 0 deletions hw08.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
---
title: "STATS 810 Fall 2024, Homework 8. <br>Internet repositories for collaboration and open-source research: git and GitHub"
output:
html_document:
toc: no

---

## Objectives

* Git has become central to collaborative computing, sharing of data and code, and open source software. A professional statistician should have at least a working knowledge of git. Git is slowly becoming incorporated into more undergraduate and graduate courses, but likely this class spans a wide range from git novices to experts. If this assignment is trivial for you, consider helping others who are new to git.

* GitHub is the largest git-based internet repository, but others (such as Bitbucket) also use git. You can use git to build a local repository on your own computer, though in practice it is usually convenient to have the repository linked to an internet site.

* Our tasks are

i. Learn some ways to think about what a git repository is and how it works.

ii. Follow the instructions below to practice going through the process of editing a GitHub repository, making a fork, and submitting a pull request.
<p><p>
__These instructions emphasize command-line control of git, working locally on a terminal on your laptop. If you have only used git in a web-based context, this may be new to you. We can discuss in class why command-line control is valuable for data science. Later, we will investigate command-line computing further, so if this is unfamiliar to you then please ask others for help as needed to get through this homework. Graphical user interfaces (GUI) and web applications can be useful in some situations, having different strengths and weaknesses compared to command-line tools. It is possible, and sometimes useful, to edit git repositories directly on GitHub, or to use a GUI on your own machine, but for this homework the goal is to study the command-line approach.__

iii. Use the self-teaching materials at [GitHub Skills](https://skills.github.com/) or [Atlassian Tutorials](https://www.atlassian.com/git/tutorials) to spend an hour or so advancing your knowledge of git. The Atlassian tutorials are good for learning command-line git, but they teach in the context of Bitbucket which is currently less popular than GitHub although both are based around the same git program. Alternatively, browse Karl Broman's practical and minimal [git/github tutorial](http://kbroman.org/github_tutorial/) which this assignment draws on.

## Questions

* **Q1**. Report briefly on your past experience with git. Describe the tasks you have previously used git for, and/or say what you learned while studying for this homework. Edit the `hw08.Rmd` file from the `ionides/810f24` GitHub repository, compile this to html (for example, using Rstudio) and submit your report via Canvas as an html file.


YOUR ANSWER HERE.

* **Q2**. Complete the pull request in step 7 of the instructions below. Check before placing your pull request that you have only edited the line with your own name. The most common reason for failing at this is using an inappopriate text editor: Do not use a web page editor, as these concern themselves only with the rendered presentation of the html, not the underling text. You are also advised not to use MS Word or Mac Notes or TextEdit, since these may add hidden lines and are not good for editing plain text files. It is useful to become familiar with one or more plain text editors such as nano, emacs, vi, pico. Code editors such as vscode and the RStudio editor can be effective for this, too, but they also may suppress some lines of text to try to improve your coding experience. If this task was not entirely straightforward for you, comment briefly on any practical issues that arose while carrying it out.

YOUR ANSWER HERE.

YOU CAN DELETE THE REMAINDER OF THIS FILE WHEN SUBMITTING YOUR HOMEWORK

--------------

--------------


## Getting started with git and GitHub

1. Get an account on GitHub, if you do not already have one.

2. If git is not installed already, download and install it from [git-scm.com/downloads](http://git-scm.com/downloads).

3. Set up your local git installation with your user name and email. Open a terminal and type:

```
$ git config --global user.name "Your name here"
$ git config --global user.email "[email protected]"
```

Don’t type the \$; that just indicates that you’re doing this at the command line. On Windows, you can run these commands in the Linux emulator provided by the git client. Disclaimer: I do not run a Windows machine, so please let me know if Windows instructions are incorrect or out-of-date.

4. Set up secure SSH communication to GitHub, following the [GitHub instructions](https://help.github.com/articles/generating-ssh-keys/).


------------------

-----------------

## Basic git concepts

* **repository**. A representation of the current state of a collection of files, and its entire history of modifications.

* **commit**. A commit is a change to one or many of the files in repository. The repository therefore consists of a directed graph of all previous commits.

* **branch**. Multiple versions of the collection of files can exist simultaneously in the repository.
These versions are called branches.
Branches may represent new functionality, or a bug fix, or different versions of the code with slightly different goals.

+ Branches have names. A special name called **master** is reserved for the main development branch.

+ Branches can be **created**, **deleted** or **merged**.

+ Each new commit is assigned to a branch.

* We now have the pieces in place to visualize the **graph** of a git repository. <small>[Picture credit: [hades.github.io](http://hades.github.io/media/git/git-history.png)]</small>

<br>
![git graph](git-history.png)

* Take some time to identify the commits, branching events, and merging events on the graph.

+ Note that branch names actually are names for the most recent commit on that branch, known as the **head** of the branch.

-----------------

----------------

## An elementary task: cloning a remote repository

* In a suitable directory, clone the class repository via an SSH connection:

```
git clone [email protected]:ionides/810f24
```

* You can also clone using https, e.g.,

```
git clone https://github.com/ionides/810f24
```

* GitHub requires an SSH connection for some actions, and so cloning by https is not recommended. If all you want to do is inspect a copy of the repository locally, https is sufficient.

* You now have a local copy of the STATS 810 class materials.

* The local repository remembers the address of the remote repository it was cloned from.

+ You can pull any changes from the remote repository to your local repository using **git pull**.

```
[ionides@doob 810f24]$ git pull
Already up-to-date.
```

----------------

---------------

## A workflow to contribute to the 810f24 GitHub repository

* If you tell me your GitHub username, I could in principle add you as a developer of the `ionides/810f24` GitHub repository. Then you can commit changes directly.

* However, here, let's practice something a bit more fancy. We will follow a standard workflow for proposing a change to someone else's GitHub repository.

### Forking a project and making a pull request

**Forking** is making your own GitHub copy of a repository. A **pull request** is a way to ask the owner of the repository to pull your changes back into their version. The following steps guide you through a test example.

1. Go to `ionides/810f24` on GitHub, for example by searching for `810f24`.

2. Click `fork` at the top right-hand corner, and follow instructions to add a forked copy to your own GitHub account. It should now show up in your account as `my_username/810f24`.

3. Clone a local copy of the forked repository to your machine, e.g.,

```
git clone [email protected]:my_username/810f24
```

4. Move to the `810f24` directory and edit the file `sign_here.html` to check your own name.

5. It can be helpful to type

```
git status
```

regularly to check on the current state of the repository.


5. Check that your change to the file is what you expected by comparing the current `sign_here.html` with the version in the most recent commit. The only difference should be the line you edited.

```
git diff sign_here.html
```

6. Commit this change to your local version of the forked `810f24`,

```
git add sign_here.html
git commit -m "sign up for my_name"
```

and see how the `git status` has changed. Another useful command for checking on the recent action in the repository is

```
git log
```

7. Push this change to your forked copy of `810f24` on GitHub:

```
git push
```

8. On the GitHub web site for the `my_username/810f24` fork, click `New pull request` and follow instructions. When you have successfully placed your pull request, the owner of the parent repository (me) will be notifed. I will then pull the modifications from your fork into `ionides/810f24`.


-------------







634 changes: 634 additions & 0 deletions hw08.html

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ title: "STATS 810 (Fall 2024)"

* [Homework 7. Negligence, mistakes & how to avoid them](hw07.pdf).

<!--
* [Homework 8. Internet repositories for collaboration and open-source research: git and GitHub](hw08.html).

<!--
* [Homework 9. Linux and the open source software movement](hw09.pdf).
* [Homework 10. Parallel statistical computing](hw10.pdf).
Expand Down
5 changes: 2 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,10 @@ <h3>Homework assignment and class notes</h3>
participants and animal subjects</a>.</p></li>
<li><p><a href="hw07.pdf">Homework 7. Negligence, mistakes &amp; how to
avoid them</a>.</p></li>
<li><p><a href="hw08.html">Homework 8. Internet repositories for
collaboration and open-source research: git and GitHub</a>.</p></li>
</ul>
<!--

* [Homework 8. Internet repositories for collaboration and open-source research: git and GitHub](hw08.html).

* [Homework 9. Linux and the open source software movement](hw09.pdf).

* [Homework 10. Parallel statistical computing](hw10.pdf).
Expand Down
26 changes: 26 additions & 0 deletions sign_here.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<h2>Sign here for STATS 810 Fall 2024 Homework 8</h2>

This is a very simple HTML file, consisting of a header, a paragraph break, and an un-numbered list. You should edit this file with a plain text editor. Check before placing your pull request that you have only edited the line with your own name. The most common reason for failing at this is using an inappopriate text editor: Do not use a web page editor, as these concern themselves only with the rendered presentation of the html, not the underling text. You are also advised not to use MS Word or Mac Notes or TextEdit, since these may add hidden lines and are not good for editing plain text files. It is useful to become familiar with one or more plain text editors such as nano, emacs, vi, pico. Code editors such as vscode and the RStudio editor can be effective for this, too, but they also may suppress some lines of text to try to improve your coding experience.
<p>
Please check your name with an <b>X</b> on the following list in your fork of the git repository, and then submit a pull request. Please edit only the line with your name on it.
<ul>
<li> <b>X</b> Edward Ionides
<li> <b></b> Parijat Chakraborty
<li> <b></b> Mihir Dhanakshirur
<li> <b></b> Khoa Bach Do
<li> <b></b> Jiwoo Han
<li> <b></b> Surtai Han
<li> <b></b> Jialin He
<li> <b></b> Seyong Hwang
<li> <b></b> Hanbin Lee
<li> <b></b> Jiaxun Li
<li> <b></b> Filippo Michelis
<li> <b></b> Dhruba Nandi
<li> <b></b> Chandler Nielsen
<li> <b></b> An Nhat Pho
<li> <b></b> Xiaoyu Qiu
<li> <b></b> Ethan Schubert
<li> <b></b> Elvin Tseng
<li> <b></b> Yue Yu

</ul>

0 comments on commit c383cf4

Please sign in to comment.