Skip to content

Latest commit

 

History

History
299 lines (237 loc) · 8.85 KB

File metadata and controls

299 lines (237 loc) · 8.85 KB

Organizing code and data: Advanced Git, Github and more

Meta

Intro

  • Introduce presenters
    • quick intro of 4 sessions
    • interrupt for questions today & expect participation
    • quick survey: commands & terms
  • Introduction
    • Screenshot of "final.doc"
      • Why is this a bad example?
        • somebody working that chaotic can make a GIT repository chaotic too
        • one person with a completely linear history is
        • docx does not work well with for diff
        • in an abstract.docx one might not need the old versions at all
        • maybe no need to maintain old versions
        • it is not clear how to split work into single consistent steps
        • not clear and maybe no need how to describe these steps
    • What is a version control system and why do I need it?
      • protects yourself and others from yourself and others (backup)
      • collaboration: work on the same project in a team without need of complicated architecture
      • don't afraid change: reverting is easy
      • mark which parts are working and which are broken (stable branch, commits under review etc)
      • review: split work into readable and consistent parts
      • apply a fix to multiple maintained branches
      • develop 5 features and deploy them in arbitrary order to the production system
    • Why?
      • GIT as solution for versioning files
        --> split work into steps (commits) --> forced to describe each step (commit message) --> branch, tags: version of software
      • GIT as solution for collaboration
      • GIT for distributing software/code
    • What?
      • versions connected via tree-like graph, each node is a commit
      • GIT: think of commit as changes ("patches")
      • Operations: branch, rebase, cherry-pick, sending commits (push/pull)
      • difference 1 to copying folders: connections (history)
      • difference 2 to copying folders: operations
      • difference 3 to copying folders: smaller file size
    • How?
      • command line
      • GUIs, IDE integration
      • API (eg. Python etc.)
  • Nice features:
    • merging
    • git blame
    • biscet
  • Git is terrible:
  • Working alone one needs only:
    • init / clone
    • commit
    • push/pull

    --> but the benefit is not very high --> explain how working with GIT works in larger teams

  • Quick-intro
  • Something went wrong... - https://ohshitgit.com/ - git reflog

  • Some hints:
    • don't leave comments in the code!
    • for command line, use a good command completion!
    • you want to have a tree viewer (terminal or GUI)
    • many commands can be aborted, like git rebase --abort
    • git add again after changing a file
  • Excercise: local repo
  • Excercise: merge conflict
    • create a feature branch
    • create a commit
  • Exercise:
    • clone some open source repository

10:15: Remotes

  • Remotes
    • Decentralized version control system
    • What is a remote?
    • http, ssh, filesystem...
    • ssh publickeys
  • Github
    • git != Github
    • Alternatives: Gitlab, Bitbucket, your own server, local folder and many more
    • Github is your business card!
    • Github stars
    • Github features:
      • README
      • Wiki
      • Issue tracker
    • Warning: Many things are undeletable
      • Commits (only by changing Sha1)
      • Pull requests
      • Issues
  • Live demo: pull request xarray: typo most -> must
    xarray/core/alignment.py
  • Fix things, rewrite history:
    • commit --ammend
    • checkout
    • reset, reset --hard
    • git rebase -i HEAD~7
    • reflog
    • revert: not!
    • https://ohshitgit.com/
  • rewriting history?
    • commit
    • rebase
    • cherry-pick
    • fetch
    • pull
    • push
  • forced push: rewriting history on the remote
    • rewrite history: rebase, git commit --amend
    • Golden rule: don't rewrite history after it leaves your machine
      • Exception: you know what you are doing and won't regret if it turns out you actually didn't
      • Exception: feature branches (or branches you own exclusively)
  • style (commit messages)
  • Excercise: push to Github
    • Clone the workshop repo with --recursive!
    • git-game
    • run as many commands as possible!
  • Exercise:
    • create a repository (on github)
    • work in it (commit)
    • somebody else breaks master (evil commit)
    • continue working and rebase your work afterwards!

11:00 Large files and workflow

  • Complete Workflow:
    • Imagine there are 3-8 developers with an idea
    • start sitting together and roughly agree on some goals, (project) names, workflow, review
    • folder structure
    • somebody creates one or more repositories and the initial file/folder structure
    • split work in tasks, go agile? :)
    • different ways:
      • every body pushes to master, maybe tags from time to time
      • feature branches & pull request, somebody approves and merges
  • Build server: e.g. Travis CI
  • what could go wrong: nothing!
    • publish private data
    • Github: issues, wiki are not deletable
    • merge conflicts might be complicated and surprising
    • start something and end in a weird state (e.g. git rebase)
      --> ohshitgit
  • GIT large files
    • git lfs
    • DVC
    • ...?

What you cannot do with GIT: - large files (Github: 100MB, everything is stored forever) - mixing public and private branches in one repository, cloning repos partially - Jupyter notebooks: nbdime

11:45 How git works

  • Hashes & Refs
    • What is Sha1?
    • Probability of hash collisions
    • Hashes can be shorted
    • For many Hashes there are symbolic names, like tags
      --> HEAD
  • GIT internals (what is a hash?)
    • .git
    • config
    • objects: files, commits
      • git cat -p file COMMIT
      • git ls-tree COMMIT
      • commmit: da483
      • file: 8e8bd5 --> cat 8bd5 | pigz -d
    • hashes
    • refs
      • HEAD
      • refs/heads
  • Fun with GIT
    • cycles in history?
    • GIT coin