What publishers need to know about git (distributed version control system)
Git is a free to use distributed version control software for tracking changes in software development. However, the benefits of using a fully-fledged version control system like git don’t just apply to writing software. Whether it’s a bug fix or a paperback edition both publishers and software developers are constantly shipping new products and revising older ones. This means that every day we perform similar sorts of tasks:
- we create a file or make changes to somebody else’s work
- we save these changes
- we come back later to make more changes
- we save again to create an updated final document
Software development is a collaborative and often nonlinear process. Developers need an effective way to share their files with their teams and to safely work on edits together. By using a version control system like git, they can track when a file was changed; why it was changed and what the contents of that change were. As publishing workflows become more complex, we will face the necessity of adopting something like git.
Publishers typically make updates within our files which means that we need to track multiple named versions or risk overwriting our work. This approach is not scalable, it leads to inefficiencies and it risks introducing errors into our files. Using git software on the other hand means that we can:
- access our files in what’s called a repository stored on our computer as well as on a server
- see the entire version history of the file at a glance
- revert to a previous git “commit” meaning we can undo changes and recover previous versions of a file
- perform a “pull request” from the repository (git name for a collection of files) we share with our colleagues and merge their work easily with our files
- work with other team members on the same files at the same time without overwriting each other’s changes or creating conflicting versions
- make it easier for others can maintain our files in the future
Git works differently to most version control systems by storing data as snapshots creating a kind of mini filing system. As commits are made the system takes a picture of the files as they exist at that time and determines how they have changed.
Git can be run using the Command Line interface (CLI) or a Graphical Interface Client (GUI) like GitHub Desktop or Tower.
The git data flow looks like this:
- On the far left in the working directory are the files we are currently editing. The staging area is a halfway stage where files wait until we are ready to commit.
- When we commit git sends our changes to the local repository which sits on our computer. We can choose to push our local repository files to a remote repository like GitHub.
- For both the staging area and the local repository there exists a checkout command which will allow us to navigate and view files from these areas.
- A fetch request brings files from a remote repository into our local repository and a pull request brings them into our working directory to allow us to begin working on them.
- We can use the merge command to combine several versions of the same file. Sometimes conflicts arise that the computer cannot integrate for instance if changes are made on the same line and git will prevent the merge until these are resolved.
- It is good practice to use branches for each separate area of your work in git. When you work in a branch you can keep on working regardless of what is happening in other branches. It’s common to keep one branch for finished work and another for testing.
- Similarly, you can fork a repository on git copying it to your computer without affecting the original project. This can be useful for using somebody else’s working as a jumping off point for your own.
Git is designed to be able to be used independently of any hosting service, but GitHub is the most popular place for users to push their local repositories. GitHub allows you to create private repositories, set access permissions, submit and track issues and accept requests and feedback. Git and GitHub used together have the potential to save your team time, foster collaboration and give you more opportunities to scale your business.
Thanks to Emma Barnes from Consonance App for the idea for this article.
For more information on using git and GitHub check the resources below:
https://guides.github.com/activities/hello-world/
https://www.freecodecamp.org/news/learn-the-basics-of-git-in-under-10-minutes-da548267cc91/
https://www.git-tower.com/learn/git/ebook/en/command-line/appendix/best-practices
Anna Cunnane is Systems and Data Manager at Abrams & Chronicle Books. Anna was winner of the Trailblazer Awards 2018, she is part of BookMachine Team Unplugged and was Chair of the Society of Young Publishers (2015-16).