5 : Git out of my way

14 Jan 2022

This week Rowan and Andy are chatting about Git. The history of it, what came before it, what other options are available and why we think git has come out as the top rated source control software.

Random fact

Every time you shuffle a deck of cards, you get a combination that's never existed. 52! (factorial 52) ways = 8.06e+67 (68 digit number)

Introduction

  • So what is GIT
    • Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows (thousands of parallel branches running on different systems).
  • History of GIT
    • Why Linus created it in 2005
      • Linux kernel developement
      • First no source control, all done via email / user groups
      • CVS / SVN weren't suitable. Centralised, merging difficult, CVS tracked changes on a per file basis, didn't recognise a larger patch as a single revision. Also nasty bugs like race conditions when 2 patches were submitted at the same time
      • Then BitKeeper (distributed, but commercial). Came under fire from community, but Linus wanted the best tool for the job, free or not
        • Needed it to be distributed so that groups of people / teams could develop parts of the kernel separately and then merge them back when ready
      • Attempts at reverse engineering BitKeeper - BitKeeper retracted free license
      • Linus made git
        • distributed
        • branching / merging fast as easy - 3 way merge - finding the common ancestor
        • efficient, accurate and performant
        • No more versions, just changes - managing changes, rather than versions makes branching and merging a piece of cake!
    • Cost
      • Git is free (open source)
  • Other options
    • Visual SourceSafe - Microsoft offering (1995)
    • SVN
    • Vault - sourcegear (proprietary)
    • Mercurial (Joel Spolsky adopted and built products around)? VHS vs BetaMax
  • Why GIT over other options
    • Distributed
    • Centralised
    • Open source
    • Well supported
    • As Joel Spolsky say - Subversion = Leeches. Mercurial and Git = Antibiotics.
  • How would you use it
    • Integrated in IDE
    • Standard flow using command line
      • GIT CLONE - clone a remote repo
      • GIT FETCH - download commits, files and refs no changes to local repo
      • GIT PULL - fetches and updates the local repo
      • GIT ADD . - adds all local changes
      • GIT COMMIT -m "comment" - records changes to the repo
      • GIT PUSH - updates the remote refs using local refs
      • GIT MERGE
    • Stash
    • Commit and push often
  • Clients
    • command line vs GUI tools - better to learn the command line
    • gui tools
      • SourceTree
      • GitHub client
      • Tortoise Git (familiar to those who used tortoise svn),
      • Fork - paid
      • GitKraken
      • Tower
      • Sublime Merge
    • Visual Studio / Visual Studio Code integration (IDE integration),
    • MergeTools
      • default linux command line vim
      • Most users want a graphical alternative to see the 3 way merge
  • Advance usage
    • Patching
      • apply commits from other branches
    • Bisect
      • Uses binary search to locate particular changes, like bugs, or some other change like a changed property.
      • Uses the concept of good and bad commits (now can use old or new as well). Start with telling git a bad commit, and a good commit, it then picks a commit between those 2 points and asks if it is good or bad, if bad, process continues
    • Cherry picking
      • Allows you to take a commit from one branch and apply it to your current branch
    • Reflog
      • The reflog is Git’s safety net. It records almost every change you make in your repository, regardless of whether you committed a snapshot or not.
  • More information

OS project/utility of the week

https://nimbletext.com/

NimbleText is a text manipulation and code generation tool available online or as a free download. It magnifies your ability to perform incredible feats of text and data wrangling. Download or use online. Command line for automation.