Git Initialization
Published: Aug 18th, 2020
This is part of Joyful Rails, a list of recommendations to make developing your Rails app more productive and joyful.
In this article, we are talking about setting up your Git repository.
When
Before you make any substantive changes to your codebase, you are going to want to store it in a version control system.
Why
Version control systems maintain a record of your changes.
This allows you to make changes with confidence because you can always see exactly what has changed and can efficiently undo it if necessary.
It makes it easy to collaborate and share code with with other people, efficiently sharing changes and ensuring they have the correct version.
Finally, version control systems make it easy to store code on remote systems, for collaboration, deployment, or just as a backup.
Git
Git is overwhelmingly the most popular version control system for computer code.
How
If you created your project by running rails new
(as outlined
here), you will already have a git repository. If not, you
can initialize your repository with git init <project_dir>
.
<project_dir>
is usually the current directory, so the command becomes git
init .
You can create a repository on GitHub to share your code or have an off-site backup.