Introduction to Git and GitHub

Dr. Mine Dogucu

Meet your instructors

What we assume you know

  • R

Outline

disseminate-collaborate-reproduce.github.io/schedule

Who uses GitHub?

Who uses GitHub?

Version control

  • hw1
  • hw1_final
  • hw1_final2
  • hw1_final3
  • hw1_finalwithfinalimages
  • hw1_finalestfinal

What if we tracked our file with a better names for each version?

  • hw1 added name
  • hw1 added question 1 image
  • hw1 changed name/ added group mate
  • hw1 added first draft of all questions

We will call the descriptions in bold commit messages.

Art of commit messages that is learned with practice

Commit often but not too often. If in doubt, commit often.

DEMO

It seems like you (I did too) wrote an R code which includes randomness but for which we forgot to set seed. Let’s correct the error while also version controlling using the repo 01-intro-github-username.

For now

Important task for now is to first commit and then push.

Cloning a repo

repo is a short form of repository. Repositories contain all of your project’s files as well as each file’s revision history.

For this workshop our repos are hosted on Github.

To clone a GitHub repo to our computer, we first copy the cloning link as shown in screencast then start an RStudio project using that link.

Cloning a repo pulls (downloads) all the elements of a repo available at that specific time.

Commits

Once you make changes to your repo, you can take a snapshot of your changes with a commit.

This way if you ever have to go back in version history you have your older commits to get back to. This is especially useful, for instance, if you want to go back to an earlier solution you have committed.

Push

All the commits you make will initially be local (i.e. on your own computer).

In order for me to see your commits, you have to push your commits. In other words upload your files at the stage in that specific time.

(An incomplete) Git/GitHub glossary

Git: is software for tracking changes in any set of files

GitHub: is an internet host for Git projects.

repo: is a short form of repository. Repositories contain all of your project’s files as well as each file’s revision history.

clone: Cloning a repo pulls (downloads) all the elements of a repo available at that specific time.

commit: A snapshot of your repo at a specific point in time. We distinguish each commit with a commit message.

push: Uploads the latest “committed” state of your repo to GitHub.

git it?