Source Code Management (SCM)
Source code is an extremely precise medium. In typical English language text, errors in spelling and grammar may be overlooked. In code, a single incorrect character -- sometimes even whitespace -- can potentially break an entire application... or worse. Simple software bugs can destroy user data, customer trust, business value and even human lives.
Are you scared yet? Because the problem is magnified when multiple software developers must work together. The structure and intent of code is quite complex and idiosyncratic. When merging code from two different people, it is terribly easy to introduce bugs.
A version control system (VCS) keeps track of every single change to every line of code by every developer over the life of a project. It provides invaluable support for process that protect against these emergent bugs. It also allows us to go back in time to examine when and where bugs were introduced.
Git
Git is a "distributed" VCS (or DVCS), a (not so) new generation of VCS. Instead of maintaining a single central VCS database on a server, every developer keeps a complete local copy of the history. Changes are made and "committed" locally, then "pushed" to a remote copy. There is still an "official" copy on a server (called origin
) with which multiple developers can synchronise, but local development is not bound to it.
Git is far and away the leading VCS in use today. Every software project should use it. Even non-software projects can often benefit from it (for example, this book developed on GitHub and published by Gitbook).
GitHub and Bitbucket are the leading providers of hosted origin
repositories. Both provide free hosting for public repositories, and have commercial plans for private repositories. GitHub charges per repository, and Bitbucket charges per collaborating user. GitHub has a more vibrant community for open-source projects, but Bitbucket private repositories are free for up to five users.
Most importantly, both GitHub and Bitbucket are well-integrated with other Web services. This simplifies the process of automating the build system. We'll explore this automation in more detail in continuous integration.
What should I do?
Sign up for a Git repository hosting account. It's up to you, but as a rule of thumb I store private repositories on Bitbucket and open-source projects on GitHub.
Assuming your project is private, I'll assume you sign up for Bitbucket.
- Create a private Bitbucket repository.
- Clone the empty repository to your local machine, or if you've already started, initialise your local working copy with Bitbucket as the
origin
remote. - Commit and push some content in a
README.md
file, and ensure it appears on Bitbucket's repository overview page.
See Also
For the academic interest of comparison, there are some alternatives to Git:
- Subversion: the old gold standard of the centralised VCS era. In common use on old SourceForge projects.
- Mercurial: Similar to Git. There are some pros and cons.
- Bazaar: Also similar to Git. More focus on ease of use, suppored by Launchpad.