Knwowledge Transfer: Git


Laurens Rietveld (laurens@triply.cc)
May 6th, 2020


Triply B.V.

Getting into Git

Aim

Get a mental model of how Git works.

Git internals

Commits

Tree: there is always* a parent commit.

Branches & tags

Your .git directory


              .git/HEAD
              .git/refs
              .git/objects
              .git/hooks
              .git/...
            

git/HEAD


              ref: refs/heads/master
            

git/refs


              $ cat .git/refs/remotes/origin/api-v-2.1.10
                9df05b942cbdd30fddfa5fb44c055cba4611052b
              $ cat .git/refs/heads/feature/4005-aclv2
                101c5284065e35abc30f5e0bf3ddfdf4c28f1cbd
            

                  git/objects/00/0b1ce13e4eb19dbe5c28a1c590932c41a17676
                  git/objects/00/14bc44f9cae3161e44a28830d50030266998f7
                  git/objects/00/459d9b4be5510e6bfcbc74e6df91685a27b584
              
  • Commits
    • Reference to parent commit
    • References to content of committed files (blobs)
    • References to paths of committed files (trees)
  • Blobs
  • Tree

Repositories

How commands map to Git internals

Common commands

git merge: fast forward

git merge: no-conflict / conflict

git rebase

  • Rebasing === rewriting history
  • Squashing commits
  • Rewriting commits as if they were created on top of a different branch
  • Never* rebase a branch used by others

Rebasing between branches

git revert

git cherry-pick

Problem-solving Git issues

Feature branch

  • We have a feature branch with several new commits.
  • It is behind the master branch.
  • We want to include these changes in master.

Backporting a commit

  • We have released our API and have a branch called api-v-2.0.0
  • A week after release, we have fixed an important bug in the master branch.
  • It contains multiple commits.

Feature-freeze

  • We have reached our feature freeze.
  • An important feature is not finished, but comitted to master.

Useful resources

Knwowledge Transfer: Git


Laurens Rietveld (laurens@triply.cc)
May 6th, 2020


Triply B.V.