As you start building the application or writing your code, you often would like to take a backup. This is where the source code management tools comes to play. One such great tool is git. Git is written by Linus Torvalds (father of Linux) and has become de facto standard today. Before git, people used to use cvs, svn, p4, hg etc.
And since you would like to take a backup of code on some other machine and would like to share your code with your teammates, the source code repository becomes essential. In organizations, there is always a single repository for entire code.
If you have a small company and you can't afford to host and manage your own repository, you would want to use github or gitlab. At github, any code you write become public.
As you write the code, you keep committing to the local repository which maintains the entire change history such that you can revert to any point in time in past.
Say, you want to try out an idea without damaging the current code. You can create branch of code using git or any other scm tools.
On the similar lines, in main repository, you could have a production branch in which only the bug fixes would go and there could be a dev branch in which you would be making frequent changes for new features and ideas.
Please learn the basics of git here: https://try.github.io/