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
Learn some ways to think about what a git repository is and how it works.
Follow the instructions below to practice going through the process of editing a GitHub repository, making a fork, and submitting a pull request.
Use the self-teaching materials at GitHub Learning Lab or Atlassian to spend an hour or so advancing your knowledge of git. The Atlassian tutorials are better 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. The Introduction to GitHub module may be a good starting point for beginners. Alternatively, browse Karl Broman’s practical and minimal git/github tutorial which this assignment draws on.
Report briefly on your past experience with git, and what you
learned while studying for this homework. Edit the hw09.Rmd
file in the 810f22
git repository, compile this to html
(for example, using Rstudio) and submit your report via Canvas as an
html file.
YOUR ANSWER HERE. YOU CAN DELETE THE REMAINDER OF THIS FILE IF YOU WANT TO.
Get an account on GitHub, if you do not already have one.
If git is not installed already, download and install it from git-scm.com/downloads.
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 "your_email@example.com"
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.
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. [Picture credit: hades.github.io]
Take some time to identify the commits, branching events, and merging events on the graph.
git clone git@github.com:ionides/810f22
git clone https://github.com/ionides/810f22
GitHub requires an SSH connection for some actions, and so the previous code is preferable. 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.
[ionides@doob 810f22]$ git pull
Already up-to-date.
If you tell me your GitHub username, I could in principle add you
as a developer of the ionides/810f22
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 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.
Go to ionides/810f22
on GitHub, for example by
searching for 810f22
.
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/810f22
.
Clone a local copy of the forked repository to your machine, e.g.,
git clone git@github.com:my_username/810f22
Move to the 810f22
directory and edit the file
sign_here.html
to check your own name.
It can be helpful to type
git status
regularly to check on the current state of the repository.
810f22
,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
810f22
on
GitHub:git push
my_username/810f22
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/810f22
.