Git
Image by git-graph
Git is a distributed version control system that helps you keep track of code versions and synchronize projects with other people on a team.
This tool is enormously helpful, even if you are a designer, not a developer. When used well, it saves time, adds flexibility, and brings clarity to team communication and collaboration.
Credit note: Huge thanks to Rachel Carmena, who created the visualisations and developed the teaching method that this segment uses.
Why is it called that?
The word “git” seems like a strange choice to many English speakers. In UK English, the word “git” means an unpleasant or contemptible person. In some dialects of American English, it is an alternative spelling of “get”, especially meaning “get out of here”.
Linus Torvalds, one of the main creators of Git, does not give us a satisfactory answer. He has said it could be any of the following:
an acronym for “Global Information Tracker,” or
a misspelling of “get,” or
an expression of the frustration we might feel doing version control, when it is cathartic to type “stupid computer” into the terminal again and again.
Choose your own adventure!
Why use it?
Have you ever been in this situation?
Without a version control system, your code projects will start to look like this.
Only worse, because with code, you have these constraints:
Interdependence of files
One change might involve touching several files, so you can’t label a change using file names.
File names
You can’t just change the names of files to describe the version - file names have to be exact for the code to work.
Bugs and bugfixes
Getting the version wrong could break everything, because one line of code could break everything.
Longevity and teamwork
The lifespan of a code project could be many years, and new people might enter a project halfway through, so you cannot rely on your memory of when you saved which files, or how multiple versions relate to each other. You have to have a system of labeling or notekeeping that makes the history clear to anyone.
Why not use Google Drive or another cloud syncing service?
Git was designed in 2005, before the advent of "the cloud" changed the way we collaborate and keep track of files. So why not use a newer, general-purpose file syncing service to keep track of code?
Control
Cloud services are generally too automatic for code, while Git waits for your explicit instruction at each step.
Metadata
Cloud services do not prompt you to label versions, so exploring the history to troubleshoot problems is more difficult. Git encourages good notekeeping through commit messages.
Branching
Cloud services do not generally provide for branching and merging, which is essential for a team working on an application that is also running in production.
Momentum
Most professional development teams use Git.
Flexibility
Cloud services often cost money and are controlled by through proprietary software by a central service provider. Git is free and open source and uses distributed architecture. If needed, an entire Git project can be restored from any copy, even if GitHub crashes or your organization has to leave GitHub.
Integration
Git integrates with services like GitHub and GitLab, which Web development teams depend on for issue tracking, code reviews, data backups, and static page hosting services. It also integrates with IDEs to show you visualisations of your project branches and commit history.
Git is a distributed version control system
repository
directory
area
repository
Cloning a repository
repository
directory
area
repository
Making changes to the working directory
directory
area
repository
Updating the repositories
directory
area
repository
repository
directory
area
repository
Tracing differences in the development environment
--staged
<commit>
directory
area
repository
Updating the development environment
repository
directory
area
repository
fetch
merge
fetch
merge
repository
directory
area
repository
fetch
rebase
fetch
rebase
repository
directory
area
repository
Branching
directory
area
repository
directory
area
repository
repository
directory
area
repository
Going further
These are the essential steps, and there is a lot more to know and explore.
For more on teamwork with Git and merging branches, see the next section on GitHub.
References
Carmena, Rachel. “How to Teach Git.” Rachel M. Carmena, December 12, 2018. https://rachelcarmena.github.io/2018/12/12/how-to-teach-git.html.
Straub, Ben. “Git Basics.” In Pro Git Book, 2nd edition., 2014. https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository.
Villalobos, Ray. “Learning Git and GitHub.” LinkedIn Learning, August 27, 2021. https://www.linkedin.com/learning/learning-git-and-github-14213624.