Git intro
Reviewedbyfl
Markdown ↓🌱
Master version control.
This is a quick intro to Git, how to set it up and how to get started with it on fortrabbit.
About Git
Git is a distributed version control system. It's quite popular to work with text files — hence in software development. It's fast, assures data integrity and supports non-linear workflows (branching). Git was developed by Linux kernel developers (including Linus Torvalds). It's free and can be used either from the command line or via graphical user interfaces.
Git can help you to collaborate on code projects, keep track of your code changes and rollback to points in time, if needed. It comes with:
- A history of all files included, so you can review or undo changes
- Powerful file merging which makes collaboration easy
On fortrabbit, Git also doubles as the deployment transport — the git push deploy tutorial shows that workflow. Git should be part of the local development setup.
Learn Git
You should be familiar with Git standard operations and concepts — these are: commit, push and pull. If you don't know Git, yet, we recommend to go ahead and learn the basics. You will profit from it either way — whether you keep using fortrabbit or not. It's a cornerstone of today's software development. For developers not used to the shell it might not be very intuitive to start with, but once you got started it soon becomes very, very handy for all kinds of things besides deploying to fortrabbit. There are many good tutorials out there in the interwebs to get started. For example:
- GitHub: Quickstart
- Official docs from Git SCM
- Try Git in your browser for free
- Guides & ebook from Git Tower
- Get Git right from Atlassian
- and many more
Install Git
To use Git, you need to have it installed on your local machine. You might already have Git: open a terminal window and type git --version. Good news for macOS and Linux users: you most likely already have it installed.
Git on Windows
You can work it out. The primary problem you have to solve is: which Git distribution are you going to use. There are multiple of those floating around, we recommend to download and install Git from the official Git website. This one comes with the "Git Bash".
The hidden .git folder
Git never forgets. It can bring back any content from any file, even deleted ones. To do so, it stores all the stuff in the hidden .git folder at the top level of the repo. Over time that file can get big too. It can also contain unreachable blobs and other stuff you are not aware of. Depending on the situation, there are many ways to clean this up: delete files of a certain type, delete the history before a certain date, or even start again from the current state.
Git desktop GUIs
Most people probably use Git from the command line (aka bash, terminal, shell). But there are also GUIs (desktop Apps) to manage Git. Those help to get started and to see visually what's going on:
About GitHub
You hopefully already know that GitHub is the most popular choice for versionized code hosting and collaborating. It is free to use with private and public projects. Sometimes people confuse Git with GitHub. Git is the version control system established by Linus Torvalds. GitHub is the service, which offers Git remote hosting and additional extra magic collaboration features. GitHub has extended Git workflows with neat communication tools around the basic Git usage. Most notable is the "pull request" workflow.
See our GitHub integration guide.
Large Git repos
A bloated Git repository is slow to clone, push, and pull. In most cases the repo can and should be small.
Large files in Git
Big binary files (> 2 MiB) do not belong in a Git repo. The same goes for most assets — images, videos, uploads. A small SVG that is part of the website layout is fine; a folder full of content images is not. Since Git never forgets, every large file bloats the history forever, even after deletion. Keep the repo to code; the deployment intro explains how code and content stay separated on fortrabbit.