Day 08 - Version control with git

Oct. 1, 2020

CMSE logo

From Pre-Class Assignment

The pre-class assignment was very long. We will take this into account when awarding credit.

Challenging bits

  • Unable to have git work for me
  • So many commands to learn!
  • The pre-class didn't make me feel ready to use git

We will work on this over time, so we can all get better at it.

Why use the git?

For yourself

  • git repositories provide a full history of everything you have done
  • with a good workflow, git repos can document a project every step of the way including problems, solutions, and todos
  • with github, you have remote copies of you work also!

On a team

  • people can work on different parts of a project at the same time
  • merging together those contributions is relatively simple
  • conflicts are explicitly raised to be dealt with

gitis the standard version control system for data science work

Using git

Common git commands

Getting started

  • git init - Initalize a new git repo on your local machine; used only once to tell your OS this directory is going to be a git repo. Creates a .git directory for that purpose.
  • git clone <URL> - Clone an existing repo located at <URL>; used only once to download the repository including the files of the most recent commit and the history prior to that commit.

Common git commands

Working with a repo

  • git add <FILE> - Adds file to a new commit; only puts the file into a staging area for commit.
  • git add -a - the -a flag adds all changed files to a new commit; it's faster, but be careful with this
  • git commit -m "MESSAGE" - commits your file to your local repo; this makes no changes to the remote repo (e.g., on github). The MESSAGE should be informative about your changes.
  • git push - Pushes your changes to the remote repository so everyone else can see them.
  • git pull - Pulls changes from the remote repository to your repo and local machine.

Common git commands

Seeing what is happening

  • git status - Tells you what changes to files have happened, if they have beens staged for commit, or if they need to be added.
  • git log - Tells you about the history of the repository

I'd be more comfortable with a GUI

GitHub Desktop is available for free. It's built for and it has all the commands you use in the CLI.

Questions, Comments, Concerns?