Software Engineering at Google Chapter #16 - Version Control and Branch Management (1 of 3)

  • VCS stands for Version Control System and modern tools such as git / GitHub are DCVS (Distributed Concurrent Version Systems)
  • Old VCS did not allow multiple users to work on the same file(s) at the same time but modern DCVS such as git / GitHub do
  • VCS are better than a shared file or directory because it allows multiple people to work on the code as the same time vs “locking a file” for one user at a time to edit
  • The VCS / DCVS is the “source of truth” for the application’s source code and optionally related files (build configurations, etc)
  • Modern VCS are called “distributed VCS” because users clone / copy / download the entire repo from a central server and thus if the server fails we can restore from a fairly up to date version of the repo from a user’s laptop
  • This allows multiple people to work on the same repo simultaneously and there is no need for users to manually coordinate their changes
  • A “repo” is a directory tree that is under VCS control
  • Each repo records a history of what changed for each file during each commit
  • Recording a history means you can roll back to a previous commit, see who made which changes, or build a binary from a previous commit (not just the most recent)
  • When a user works on source code that is under DCVS control they start by copying a repo from a server to their laptop
  • After a user makes changes they “commit” their work and the changes are pushed from their laptop back to the server
  • Each time a user pushes their commits to the repo the server determines the different between the user’s changes and the latest version
  • Each repo has a main branch and that is called the head, trunk, master, or default branch. Changes are merged into this branch.
  • In summary...
    • Each user works on his or her own branch to make changes
    • The branch is pushed to the server
    • The code is reviewed
    • The code is merged into the head / trunk / default / master / main branch



Thank you for your time and attention.
Apply what you've learned here.
Enjoy it all.