Version control systems (VCS) start with a base version of the document and then keeps track of changes you make each step of the way
VCS are essential for developing software and carrying out projects with a lot of code
VCS does not care about file names, intead records who, what, when, and why changes were made to files
One of the most popular VCS tools in use today is called git
It is a command-line tool that is installed locally
It is free and open-source software
git
VCS acts like an unlimited 'undo' thereby protecting source code from yourself and others
e.g. catastrophe, human error, and unintended consequences
VCS enables many people to work on the same project at the same time
Teams working in parallel accelerates project development
Impossible for junior developer to mess up a big project
Since it is so robust this encourages open-source experimentation and development
GitHub
has really emerged as the industry standard
One team member makes changes (e.g. add, modify, delete) to files on their local machine
Periodically, they should commit these changes (i.e. take a snapshot) with a short message saying what they did
When they are finished working, they can push their changes back to the central repository
Team member then resolves any conflicts between their local version and the central repository.
Once finished, team member can then commit and push their changes to the central repo
The logical extension of the centralized workflow is to use branches
In this workflow, all feature development takes place in a dedicated branch instead of the main branch
This means that main branch never contains broken code - a huge advantage for continuous integration environments
When team members finish their changes, they push their branch to the central repository. The central repository will now contain multiple branches.
Therefore, unlike the centralized workflow, this push will never cause conflicts
Team leader reviews pull request, discusses any changes with team members
Once everything looks good, team leader merges new feature into main codebase
Team member can then delete their branch
Promotes collaboration with team members through pull requests and merge reviews
Teams can work in parallel on same files so good approach for larger teams
Main branch never contains broken code
Guiding framework for other, more complex worflows
Instead of using a single, central repository, forking workflows give every team member their own central repository
Team members can tinker with their forked repository as they wish without disturbing anyone else
When ready they can push to their private central repository and file pull requests if they think their changes are ready to be integrated to main codebase
Provides a little more power to the team leader because they are the only person that can push to the official repository
Allows the team leader to accept/reject commits from any developer without giving them write access to the main codebase
Often used for large open-source projects
It is important that teams establish shared patterns of collaboration
If a team doesn't agree on a shared workflow it can lead to inefficient communication when it comes time to merge branches
Commits are easy to make and provide opportunities to revert or undo work
They should be made frequently to capture updates to a code base
VCS enables rapid updates from multiple developers
It's easy to have a local copy of the codebase fall behind the global copy
Make sure to git pull
or fetch
the latest code before you start working on project
It is important to leave descriptive explanatory commit log messages. These commit log messages should explain the "why" and "what" that encompass the commits content.
These log messages become the canonical history of the project's development and leave a trail for future contributors to review.
Branches enable multiple developers to work in parallel on separate lines of development
Branches should be used frequently as they are quick and inexpensive.
When development on a branch is complete it should be merged into the main line of development and then deleted